Questions tagged [performance]

Performance is a subset of Optimization: performance is the goal when you want the execution time of your program or routine to be optimal.

Filter by
Sorted by
Tagged with
3
votes
1answer
100 views

How to make my “custom integer type” perform better?

During a project at my work I needed a convenient way to store values taking up the smallest amount of bits necessary, not in memory but later when they're serialized into an array of unsigned short ...
2
votes
1answer
35 views

Edit file name method - run time complexity

I wrote a function in Java that edit file name, and replace each space char into dash char. Currently I iterate all the files in a specific directory, iterate in each file name, creating a new file ...
-1
votes
1answer
41 views

Reduce CPU utilization in constant pinging to API and saving data in to database service [on hold]

I have this hosted service which grabs the data from API every second and process the data and save it into the database. I have similar 3 more hosted services which run at the same time. Because of ...
10
votes
3answers
875 views

Karazuba Algorithm with arbitrary bases

I'm working on an implementation of the Karazuba Algorithm. I created a class BN which represents a number in an arbitrary base (and supports elementary operations)...
5
votes
2answers
52 views

Looking for performance improvement of my custom dataframe aggregation function (Python/Pandas)

I would like to aggregate rows of my dataframe together, following those rules: Rows are grouped by "Id", and sorted by anticipation One row can only be aggregated with rows next to it, with the ...
1
vote
0answers
45 views

Single-player obstacle-avoidance space game

I was wondering what I could do to improve the gameplay of this game, as well as the graphics. I would like to use LWJGL, but the rendering library isn't important. I just need to find out ...
3
votes
2answers
70 views

Large matrix with lots of repetitive fields (C++)

I wrote a timetabling program and I have been using a matrix to check for clashes between courses. Index (i, j) in the matrix ...
0
votes
0answers
18 views

bash script at scale for kubernetes kubectl operations

I have my below prototyped script and it runs fine but I need to scale it out at large. So, wanted to get feedback if my script can be improved in terms of performance and if there are any non ...
1
vote
3answers
168 views

Primality test in Python

Here is a working Python implementation of primality test. Is there something that I could change in code to achieve a better running time? For more information about algorithm see this post. ...
13
votes
2answers
950 views

Mean π: Archimedes vs. Gauss - π computation through generalized means

I've written this simplified code to compute Pi for educational/demonstration purposes. These methods are based upon the generalized means: see a presentation on Pi and the AGM. Archimedes' method ...
0
votes
0answers
18 views

Two functions vs Arguments based in single function [closed]

I always find myself in dilemma when creating functions which requires to change state based on arguments. Review below code and suggest what should be the best way. Classic example for this problem ...
3
votes
1answer
44 views

Making a grid for collision detection in a game that wraps

I'm making a 2D game which wraps (when you move off the right edge, you appear on the left, etc). The game area is square, all objects are circles (with AABB smaller than the game area, and in most ...
4
votes
1answer
56 views

Incremental Sieve of Eratosthenes Generator

So I was fiddling around with the Euler challenges. One of the things they mentioned in their discussions of the solutions is the Sieve of Eratosthenes and that you can only use it when you know an ...
5
votes
1answer
54 views

c++17 compatible std::bind_front alternative

One of the things that has been really exciting me in c++20 is std::bind_front. Using placeholders with std::bind and ...
2
votes
1answer
61 views

LeetCode - Merging piles of stones

This is a LeetCode Problem You have a pile of stones presented as an array. On each turn you must merge k consecutive piles of stones, starting from any pile you wish. You must continue merging ...
2
votes
2answers
87 views

Get the Nth Term in the Fibonacci Sequence

I'm trying out a new editor (CLion) and I decided to try an old well known programming problem. I also decided to try out C99 rather than C89. This program calculates the nth term of the Fibonacci ...
-4
votes
0answers
40 views

Array Movement Speed [closed]

I have 2 arrays that are given to me. The second array is considered as the first array after 1 second The distance that it has moved is calculated FRAME: 1 1 1 0 0 1 1 1 1 1 0 1 1 1 1 1 0 0 1 1 ...
2
votes
1answer
52 views

Arbitrary precision Euler-Mascheroni constant via a Brent-McMillan algorithm with no math module

Utilizing the below relation, I am able to compute the Euler constant to great precision on a single thread quickly and simply. My process is to compute the natural log via the AGM(utilizing Pi an ...
0
votes
0answers
24 views

Speed up auto encoder training without breaking anything

I'm training a GRU auto-encoder and my current code is very slow.I believe it's predict_captions function that takes most the time. Any suggestion to optimize this code? ...
-2
votes
0answers
40 views

Excel VBA Sub Routine is extremely Slow deleting a Range

The following script is very slow and I'm not sure why. The script works so if you copy and paste its a typo in the question. ...
4
votes
1answer
53 views

Calculate the Euler-Mascheroni constant without the math module

The below code was written to generate γ, for educational purposes. Single threaded, no functional zeroes required, no binary splitting(which can all be used to compute competitively like y-cruncher, ...
1
vote
0answers
31 views

Checking for a values existence: slice iteration vs map lookups in Go [closed]

Assuming I have the following slice: mySlice := []string{"one", "two", "three"} and I want to know whether or not it contains a given string, say ...
6
votes
2answers
93 views

Mandelbrot rendering code in R

I'm trying out a new continuous histogram coloring method for Mandelbrot rendering in R, and since it requires three loops (three passes), each of them doubly nested, there should be a way to ...
28
votes
8answers
4k views

Project Euler Problem 45

As a self-teaching Python beginner for almost 4 months, I have mostly been doing online challenges including Project Euler problems. Problem 45 asks: Triangle, pentagonal, and hexagonal numbers ...
1
vote
3answers
91 views

15 line Rust program, which writes the numbers 1 to N to a file

I have this simple Rust program, which creates a file called numbers.txt and writes the numbers 1 to N (N is here 10000000) to it, separated with newlines: ...
3
votes
1answer
39 views

Monitor a web page for when a desired price is met

I have a code that keeps checking a webpage with a price on it and when the price meets a number I set it to, the thing is purchased. I am looking for ways to increase the speed of it. I have added ...
0
votes
0answers
32 views

Measure durations using a calendar table

For a report, I have, among other things, to count the amount of days between two dates on the same entry and group them by month. ...
4
votes
2answers
63 views

Looping through two lists and randomly aggregating elements to equal an element from another list

I have three datasets, "CV", "FV" and "LA". I have attached reproducible data for all of them. The idea is that some combination of the elements in each column of CV and FV should sum up to equal the ...
3
votes
1answer
30 views

Enforcing a constraint that a user may vote on each post at most once

I have the following table in a PostgreSQL database: ...
4
votes
2answers
58 views

Pulling financial data via IEX Cloud API

I am pulling some financial data from the IEX Cloud API. Since it is a paid API w/ rate limits, I would like to do this as efficiently as possible (i.e., as few calls as possible). Given that the <...
2
votes
1answer
31 views

Speed up shapely buffer

I was asked to move the code here. I have different shapely.LineStrings like so: which I then buffer to create a polygon like ...
1
vote
1answer
55 views

Code improvement suggestions for cost calculation [closed]

I have to calculate costs based on country code and city(optional). There is also a condition that countries in Asia have separate pricing logic depending on both country and city and they are stored ...
0
votes
0answers
16 views

Copying cells with apache-poi

I am using apache-poi to copy excel files while also altering a few things on them. While copying, the styles, values and formulas should be retained. Yet, some formulas need to be replaced with their ...
1
vote
1answer
47 views

Is there better alternative to making an optional set of elements from iterable in java?

I'm feeling uneasy with this service method that I wrote: ...
1
vote
0answers
40 views

Fast text search in Rust

I have a large file that I want to search for text as fast as possible. There is not a memory contraint, so I am loading the entire file into memory so that I can use the rayon parallelism crate in ...
2
votes
0answers
47 views

Bash bitcoin blockchain explorer

I wrote a little bash script that displays the transaction info in json: ...
1
vote
1answer
49 views

Rust program, which reads, processes, and writes a file

I'm making a small program to benchmark Rust's performance compared to some other languages. The idea I came up with, was to take a file (with the numbers 1 to 10000000 written to it in separate lines)...
10
votes
2answers
1k views

IList<T> implementation

I was wondering about the possibility to create an implementation of IList<T> that is faster than List<T> using C#, ...
2
votes
1answer
54 views

Multithreading to process requests and save results in python

I was presented with a task to come up with a script that generates a CSV with POSTAL codes via bruteforce (I'm in Brazil, so that means CEP to us). Points to note: I'm using an external library, ...
1
vote
0answers
24 views

GUI table widget filling with nested for loops

I'm doing a larger PyQt5 project which includes loading in large amount of data into a QTableWidget. However filling the table up with the loaded data is extremely slow due to nested for loops. I put ...
1
vote
0answers
52 views

AES encryption/decryption in rust: performance and best practices

I wrote a small rust library available on github that can encrypt/decrypt a 16 bytes block using either 128, 192 or 256 bit passwords. This implementation is tested with the test data provided in the ...
2
votes
0answers
40 views

Motor control PLC in Python

Project description We have different types of devices like sov, motor, analog, digital, control valves etc. Each type of device has 100 items. Now our software continuously monitors with the PLC to ...
1
vote
1answer
61 views

Add watermark to images

Recently, I started reading image processing via opencv library in python. I create a minio object storage and upload some photos into it. After that, I wrote a program which reads every image in ...
2
votes
1answer
39 views

Highlight strings that match a search term

I'm writing a ctrl+f function so to speak in React that allows a user to search for a term in a list of words, and if the term matches any of the words in the list then it highlights it. To do this, I'...
14
votes
5answers
5k views

Printing a list as “a, b, c.” using Python

Is there a better way to do this? Assuming very long lists, is this slow and wasteful? ...
4
votes
2answers
95 views

Data structure that retrieves each item with a specified probability

I wanted a data structure that allowed me to set the chances of randomly returning each of it's elements. For example, suppose I have a Human class. Every Human has an attribute called eyeColor. I ...
2
votes
1answer
52 views

Loop to extract json from dataframe and storing in a new dataframe

I have a dataframe (obtained from a csv saved from mysql) with several columns, and one of them consist of a string which is the representation of a json. The data looks like: ...
1
vote
2answers
125 views

Is it worth to compromise on speed to follow PEP 8 guidelines? [closed]

I have this long line of code: enc = encoder.predict(np.array([data[stock][4*i:4*(i+30)] for i in range(lens[stock]+days-30)])) The problem is, the number of ...
4
votes
1answer
66 views

Count words with given prefix using Trie

I have been trying to solve this HackerRank problem: We're going to make our own Contacts application! The application must perform two types of operations: add name, where is a string ...
1
vote
0answers
34 views

Indexing documents in Elastic Search using Refresh.True - Performance hit and how can it be improved? [closed]

I have an AWS Elastic Search server. Using mapping template and an index strategy. ...