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
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: ...
Nathan Osman's user avatar
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 ...
Oliver's user avatar
  • 93
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 ...
Kevin Krumwiede's user avatar
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). ...
Mukul Kumar's user avatar
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 ...
evirac's user avatar
  • 23
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 ...
bit's user avatar
  • 143
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 ...
Глеб's user avatar
  • 183
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, ...
g3tl0st's user avatar
  • 111
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 ...
Rajdeep Malakar's user avatar
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 ...
iogamesplayer's user avatar
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 ...
sidnb13's user avatar
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 <...
mascai's user avatar
  • 397
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 ...
trxgnyp1's user avatar
  • 111
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 ...
PrancingCrabulon's user avatar
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 ...
Ξένη Γήινος's user avatar
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 ...
Long nguyen duc's user avatar
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 ...
Toby Speight's user avatar
4 votes
2 answers
557 views

Miller-Rabin Primality Test in Python

I have the following implementation of the Miller-Rabin test in Python: ...
pointySphere's user avatar
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 ...
x27ca61a's user avatar
  • 307
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, ...
DizzyDazzo12's user avatar
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 ...
visionary's user avatar
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. <...
GuntherOnFire's user avatar
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. ...
Big_Port's user avatar
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 ...
Python coder's user avatar
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: ...
Ari Fordsham's user avatar
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: ...
PyNoob's user avatar
  • 21
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 ...
Ξένη Γήινος's user avatar
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) ...
Marc's user avatar
  • 33
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 ...
Ξένη Γήινος's user avatar
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 ...
Blindman67's user avatar
  • 21.6k
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 ...
Rustam Abdiyev's user avatar
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/...
b1tflpr's user avatar
  • 43
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. ...
Eden Laika's user avatar
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 ...
Ξένη Γήινος's user avatar
-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 ...
Sanyou's user avatar
  • 3
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 ...
Kimi M's user avatar
  • 101
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 ...
Kendall Briggs's user avatar
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. ...
Michael Granger's user avatar
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 ...
Ξένη Γήινος's user avatar
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 ...
philo math's user avatar
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. ...
matts's user avatar
  • 53
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 ...
Kale 's user avatar
  • 33
-2 votes
2 answers
120 views

Lower-Bound algorithm getting Time Limit Exceeded

...
Shakhawat Hossain SHIHAB's user avatar
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 ...
larssonmartin's user avatar
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 ...
Yoshiro's user avatar
  • 29
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 ...
Pel de Pinda's user avatar
0 votes
0 answers
28 views

MySQL join query to link valuations with associated valuation tasks

...
Michael LB's user avatar
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, ...
Khaled's user avatar
  • 309
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 ...
mehdi mirzaie's user avatar
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 ...
Kraust123's user avatar