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.
8,706
questions
0
votes
0
answers
15
views
specify a policy for allowing access to a table through a foreign key
Consider the following two tables in a PostgreSQL database:
...
3
votes
1
answer
90
views
Performance of this BCrypt lossless compressor
The following code compresses a 60-byte BCrypt MCF into 40 bytes.
Does anyone see room for performance or other optimizations?
For example, I should replace Guava's ...
0
votes
0
answers
36
views
Testing the cost of boxing in System.Reactive Observables
I was curious whether boxing impacts performance in a long chain of IObservable<T> operators where T is a value type, and ...
8
votes
8
answers
3k
views
Can I lessen the use of boolean flag variables in this snippet?
Below snippet is part of a game application's logic and the Update function is called every frame (about 60 times a second).
...
2
votes
3
answers
605
views
Count the number of triplets from an array with sums divisible by 'd'?
I got this question on my test and I did the only logical thing I could think of, which is run 3 nested loops and count each triplet. I obviously wouldn't pass test cases for large arrays...
How can I ...
0
votes
1
answer
43
views
Aggregate transactions in slips
I wrote code to aggregate transactions in slips. I'm concerned with the performance of my code because it uses 3 loops that are nested so the time complexity will be cubic. This code won't scale well ...
8
votes
3
answers
2k
views
Algorithm "sort except zero"
Task:
Sort the integers in sequence in sequence. But the position of zeros should not be changed.
Input: List of integers (int).
Output: List or another Iterable (tuple, generator, iterator) of ...
1
vote
1
answer
76
views
Getting one company from two tables [closed]
Currently I'm working with fastapi, sqlalchemy to connect to multiple databases. It checks params to ensure it has company_name, ...
4
votes
1
answer
46
views
ShareImage: Place Texts on Images to generate Social Media Preview Images
ShareImage is a project which lets you use an Image ("Template") and place text over it, to generate Social Media Preview Images, the ones used in the ...
8
votes
4
answers
2k
views
Plotting the Mandelbrot set efficiently
This is my Mandelbrot set program - it includes Smooth Coloring, perodicity checks, and my approach to biomorphs.
I know of Edge Detection, but I couldn't find a simple explanation that I can ...
0
votes
0
answers
18
views
Efficiently computing a batch of results given a batch assignment vector and series of corresponding matrices
I have a 1D tensor of tokens that belong to different batches. The batch sizes here are uneven. Each batch needs to be multiplied with a corresponding weight matrix. My current approach is using a ...
1
vote
1
answer
78
views
Process comma separated input and check format
I have to read console input and store data in the vector of structs. In case of any data format violation I have to print "Malformed Input" and return <...
0
votes
2
answers
102
views
Improving performance of mandelbrot set calculation
I am making a hobby OS, and I thought about adding a command for interactively rendering the Mandelbrot set. The "interactive" part is not really important, but I wanted to check if the ...
1
vote
2
answers
167
views
Two sum sliding window challenge
The task is a simple coding challenge I took part in. It is a spin on the two sum problem.
In the two sum problem you are given an validation sequence A and a test input I. I is valid if it's the sum ...
4
votes
2
answers
135
views
NumPy script to convert BGR to HSL and back
This is a NumPy script that converts BGR arrays to HSL arrays and back, without using OpenCV. Input and output values are arrays of 3 dimensions with values ranging from 0 to 1, the shape of the ...
2
votes
1
answer
44
views
Interpolate raster value using Python
I'm new in coding.
I have a shapefile (points) and some raster files. My purpose is get the values from all raster to point (each point will get value from 2 or 3 nearest cell,the value on the value ...
2
votes
1
answer
50
views
Find perfect and amicable numbers
I've been playing with perfect, amicable and social numbers lately, and created a class for investigating these. At present, it has functions to return the perfect and amicable numbers in a specified ...
4
votes
2
answers
557
views
Miller-Rabin Primality Test in Python
I have the following implementation of the Miller-Rabin test in Python:
...
3
votes
1
answer
84
views
Simulate M random walkers N times and visualize relationship between walker number and grid size
Problem statement: Suppose that n random walkers, starting in the center of an n-by-n grid, move one step at a time, choosing to go left, right, up, or down with equal probability at each step. Write ...
2
votes
2
answers
783
views
How can I get my CPU Utilization Down? PYGAME PROJECT
I get 25% CPU usage on this simple project. I hope it's okay if I just post the whole thing. It probably something to do with the rendering code. It's definitely the project though, my fans get loud, ...
2
votes
0
answers
64
views
Create a Penrose tiling
I programmed this type of Penrose Tilings in javascript and the algorithm is 'simple':
The cyan pentagon always have to draw the yellow losenge and the grey pentagon almost always have to draw two red ...
4
votes
3
answers
779
views
Codewars: Multiplying Polynomials
I'm trying to solve the following Kata from Codewars in Python.
My code produces the desired result for all the tests, yet it is not optimal, so it takes too much time to accomplish the big tests.
<...
2
votes
1
answer
86
views
Count the Streaks in a coin flip and display the number of Head vs Tail Streaks
Like title says programs shows you the number of streaks and how many of each. Is there anyway to break this down. Feels like it's too many variables.
...
4
votes
2
answers
2k
views
Install specific version of Python in docker
Downloading specific version like 3.11.1 from https://www.python.org/ftp/python/3.11.1/Python-3.11.1.tgz and installing ...
4
votes
2
answers
675
views
Performance of Haskell prime sieve
I have this code, which is a pseudo-Sieve of Eratosthenes for generating primes:
...
1
vote
2
answers
52
views
Imrove performance when updating DataFrame rows based on complex criteria
My question got rejected the last time so I am trying a better approach to getting a solution:
...
1
vote
1
answer
129
views
C++ arbitrary base convertor
This is my second C++ program. Again, I wrote it all by myself. I only started learning C++ yesterday.
The concept of the program is simple; it should read input from ...
3
votes
1
answer
140
views
Custom single-header C++ logging library
I started learning C++ recently for game development, and decided to write my own little library for debugging.
Here is the library (snoop.hpp)
...
8
votes
3
answers
2k
views
Sieve of Eratosthenes in C++ with wheel factorization
I have written a completely working C++ program for the first time, and I have managed to compile it. I have decided to learn C++ and I have written a C++ program to familiarize myself with C++, this ...
2
votes
1
answer
82
views
Object pooling class BubbleList
Please review C++ class BubbleList design with performance in mind.
Named BubbleList as pooled (unused) objects bubble to the ...
0
votes
4
answers
110
views
Code counts the number of identical elements between the arrays 's' and 'd' at the same index
I wrote a code and the code counts the number of identical elements between the arrays s and d at the same index. I need to ...
3
votes
1
answer
226
views
Python Script to Calculate Historical S&P 500 Returns over Requested Time Span
I have a Python script that calculates the historical S&P 500 returns from a starting balance and annual contribution. The script also outputs interesting statistics (mean/min/max/stddev/...
5
votes
1
answer
75
views
Generating Abelian sandpile "zeros" in python
Here is some code that generates the zero element of an Abelian sandpile model (ASM), for any given model dimensions, and then plots the result as a colormesh. Here is a wiki page explaining the ASM. ...
4
votes
1
answer
298
views
Python IP geolocation script
These are two Python scripts I wrote to convert a GIGANTIC text file of over 100MiB in size (the current version is 152.735MiB) to an SQLite3 database to use for geolocation, and the script that ...
-1
votes
1
answer
70
views
Find the first value bigger than a threshold
This function takes two inputs: A is 2D (N,5) while B is 1D (N).
It tries to find the smallest ...
9
votes
3
answers
2k
views
Repeatedly remove a substring quickly
I'm trying to solve the USACO problem Censoring (Bronze), which was the first problem for the 2015 February contest. My solution works for some test cases, but then times out for test cases 7-15. I ...
3
votes
0
answers
180
views
A vehicle database in Excel
I'm looking for some help. I'm new to coding and have started creating this Vehicle database program in Excel for a friend to use.
He is wanting to be able to see all vehicles he owns, when ...
2
votes
1
answer
98
views
USACO Arithmetic Progression
The problem statement:
An arithmetic progression is a sequence of the form a, a+b, a+2b, ..., a+nb where n=0, 1, 2, 3, ... . For this problem, a is a non-negative integer and b is a positive integer.
...
0
votes
2
answers
169
views
Python script that makes generalized Ulam spirals
This is a Python script I wrote to generate generalized Ulam spirals.
I call the spirals generated by my code Ulamish spirals, they are one dimensional polylines that cross all two dimensional lattice ...
1
vote
2
answers
74
views
Changing every link on page, in fastest way possible
I have created a script (mediawiki gadget), which iterates over every redlink in a rendered wiki-page (that is, over every href with class new, signifying an ...
5
votes
2
answers
451
views
Optimizing a node search method given a 2-D spatial point
I have a tree-like structure called grid. I have designed it as a structured numpy array. Each element of grid is a tree-node. ...
2
votes
1
answer
142
views
Is this the right implementation for Linear Programming (puLP) on python?
I have created a LP function to help maximize a set of features. My first time playing with this library and also conducting LP.
Variables:
Number of features => X
Number of Categories => Y
...
-2
votes
2
answers
120
views
5
votes
3
answers
2k
views
An exercise in Data Oriented Design & Multi Threading in C++
Been working in games development professionally now for about ~5 years, but have only been doing OOP & haven't worked with multi threading before as I'm mostly a gameplay programmer, I've also ...
1
vote
4
answers
254
views
Suggestions on performance
I have following piece of code that is called by a program many thousands of times as part of Monte-Carlo simulation. using gprof, I see that 38% of the time was spent on this function. Are there any ...
11
votes
5
answers
2k
views
Calculating standard deviation
I am getting about 215 MB/s throughput on this implementation of Welford's algorithm. My hard drive is rated for 400 MB/s reads, so I am wondering how I can optimise this. I assume the bottleneck is ...
0
votes
0
answers
28
views
2
votes
2
answers
108
views
Increasing writing speed to file inside a for-loop for large files
I have a .csv file containing 100 millions records, I would to create multiple files from this file, after certain condition satisfied in each line, I came to this code below, but it is slow, I think, ...
8
votes
3
answers
2k
views
Newton Fractal writen in C
The code has no errors, it is just slow. It takes 1.19s to start.
How can I reduce runtime without using threads or multiple processes?
I have tried compiler optimization
...
0
votes
1
answer
140
views
Optimizing LINQ Query on C# Web API
Can someone help me optimize this code especially the LINQ query. It takes 8-12 seconds just to return a response when I'm calling the endpoint. Its super slow, and my whole endpoint call is taking ...