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,703
questions
1
vote
0
answers
85
views
Python integer optimization with PuLP involving polynomials that I think can be faster
I have a problem where we are given multivariate polynomials in variables like y_i and z_j and the goal is to express them as sums of products of terms of the form y_i-z_j with nonnegative integer ...
0
votes
2
answers
36
views
Optimisation: Conversion from int to Roman Numeral
A while ago I made a post about optimising the multiplication of every number in an array by 2. With everyone's help I was able to go from 1,500 ns (LINQ) to 30 ns.
So I thought I'd try something ...
0
votes
1
answer
27
views
Find and conditionally sort all venues matching a filter provided by an API client in PostgreSQL
I have an API where users can retrieve a list of "venues".
Every venue is a profile, but not every profile is a venue
Venues can be "parents" of other venues (think hotel - floor -...
4
votes
1
answer
133
views
calculate the number of ways to pick two different indices
I'm working on a codesignal practice problem
You are given an array of integers a and an integer k. Your task is to calculate the number of ways to pick two different indices i < j, such that a[i] ...
1
vote
1
answer
138
views
Sort by year and day descending, yet time ascending
I recently discovered a hugely inefficient portion of code in my program, and have gone about rewriting it. I am however, not quite sure if the rewritten program actually does exactly what I want, due ...
2
votes
0
answers
34
views
SEDE query to count questions, views and unanswered for a set of tags
This query selects the number of SO questions, the number of views and the number of unanswered questions for each tag (the list of the tags is the user input). It works fine when it works, but it ...
0
votes
1
answer
29
views
Print a hollow Rhombus [closed]
I am beginner in java, here is my code to print a hollow rhombus:
...
3
votes
2
answers
377
views
Find the UTF-8 Length of a given codepoint
A codepoint in UTF-8 can be represented by one to four bytes. Given a codepoint, I need to determine the length (in bytes) of the codepoint if it were represented in UTF-8. For this, I've written the ...
2
votes
0
answers
76
views
NLP pre-processing function optimization as it is extremely low on 92Mb data set
I have a data set that is of 300,000 rows approximately and two columns, each row contains a string, some might be larger than others. All in all, the data set in a ...
6
votes
1
answer
76
views
Optimizing __getitem__ for a bioinformatics script in Python
I'm writing a script for a bioinformatics application in Python that iterates through several sequences looking for amino acids in specific positions to calculate their frequency in relation to a ...
11
votes
3
answers
11k
views
Sum of all possible concatenations of array values
Given an array of non-negative integers, we need to find the sum of concatenation of elements in the array.
For example -
given [11, 22] the result should be - 6666
i.e.,
11 + 11 = 1111
11 + 22 = ...
4
votes
2
answers
438
views
Spatial radius search in Boid simulation
I am working on a Boid simulation with 10,000 boids. I've successfully utilized geometry shaders and an array<GLfloat[3], MAX_BOIDS> for vertices to enhance ...
3
votes
1
answer
87
views
Pentomino solver in Python
When I was a child, I used to play Ubongo board game, recently I discovered Pentomino puzzle and I wanted to create a custom solver in python for it. Here is what I got:
...
0
votes
1
answer
69
views
Changes hash to allocate values as directed
Let's say you have a hashmap of sub-systems that a spaceship is currently directing power to and a second hash of sub-systems where the power should now be directed to.
Create a function that returns ...
1
vote
0
answers
57
views
My code.org Game Lab project is running really slowly, how can I optimize the code further?
I'm working on my final project, and it is a game made with Java Script in code.org's Game Lab. The code worked fine, and it was not slow at all, but as I worked on it, it became much slower! The ...
3
votes
1
answer
89
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 ...
4
votes
0
answers
153
views
Optimizing a Wordle Solver in JavaScript
I have written a Wordle solver in JavaScript.
The solver generates a decision tree. For each word, it generates all possible feedbacks patterns for that word, it then selects for each pattern the word ...
1
vote
1
answer
106
views
Reviews a daily fantasy slate to check for duplicate lineups
My code below is used as a back testing tool to review a past Daily Fantasy Sports slate. This code works perfectly but when the contest size (total entrants) gets up to the 30,000 range it takes ...
2
votes
2
answers
154
views
Given an array, remove zero or more elements to maximize the reduction where you add odd values and subtract even values
Here's a code challenge I got. (I could not solve the challenge, I ran out of time. I rephrased the challenge language and I am trying the challenge again for personal growth & computer science ...
3
votes
2
answers
266
views
Trailing Digits
https://www.acmicpc.net/problem/23204
I've solved a programming challenge where you need to count the occurrences of a specific digit at the end of the product of multiples of a given number within a ...
0
votes
0
answers
20
views
matching generic items
Hello fellow developers
I was wondering if anyone, with more understanding of javascript, is able to detect some potential flaws or performance issues with this recursive function.
It works as ...
1
vote
5
answers
176
views
Finding a distinct triplet where the sum of the values is divisible by a given number
Given an array a and a number d, I want to count the number of distinct triplets (i,j,k) such that i<j<k and the sum aᵢ + aⱼ + aₖ is divisible by d.
Example: when a is ...
4
votes
2
answers
423
views
Continuously Monitoring ICY Stream Metadata (Title, Artist)
This script is called every minute, but I want it to run continuously instead of making that many requests to the radio station and I think that urllib.request can ...
4
votes
2
answers
116
views
Python (API requests)
I'm somewhat new to python and I'm creating a script that requests to a certain API and then uses the response to populate a ...
3
votes
1
answer
200
views
Project Euler 60: Prime Pair Sets
Project Euler Prime Pair Sets:
The primes 3, 7, 109, and 673 are quite remarkable. By taking any two primes and concatenating them in any order the result will always be prime.
For example, taking 7 ...
0
votes
2
answers
144
views
Python: Detect if a number is divisible by any number in a list
I am trying to filter steps such that it only contains numbers from 1 to step_size that aren't divisible by factors of ...
0
votes
3
answers
68
views
another Merge Sort
I've tried to implement merge sort in c with varying degrees of success, one was correctly sorting the array but leaking memory, one was neither sorting the array and leaking memory.
The following was ...
0
votes
1
answer
131
views
Training a Reinforcement Learning algorithm
Problem:
I'm trying to reduce the computation time and optimize specific functions of a Reinforcement Learning algorithm in the training phase and observed that one block of code takes too much ...
0
votes
1
answer
65
views
Distance on a unit grid
I have a code that calculates Euclidean distance on a grid with border crossing or without that.
...
1
vote
0
answers
51
views
3ph 2l inverter simulation with SPWM
Here is a code for a simple model of three phase two level inverter with constant DC voltage source and three phase RL load.
...
0
votes
0
answers
68
views
C# chess engine performance
I am creating my own bitboard chess engine in C#. I am trying to optimize my make move, unmake move, and move generating functions to get a good fast base. My C# skills are average and got some tips ...
3
votes
1
answer
219
views
Find the closest named color
I have a .json file with name (string) and RGB (r, g, b: numbers) with 30.000 key-value pairs. I am looping the json multiple times per second to find the closest name to a given RGB color. Any idea ...
3
votes
1
answer
67
views
Multi producer/consumer lock-free queue
I would be grateful if you could review my code for a multi producer/consumer lock-free queue in C++.
I am mainly after performance improvements, but all input is welcome.
...
0
votes
1
answer
184
views
How to optimize the player movement code like in Tomb Of The Musk game?
I've written some code that performs movement similar to the Tomb Of The Musk game. The idea is that the objet should move in a certain direction until it encounters an obstacle. After that, the ...
2
votes
5
answers
434
views
Optimisation: Fastest way to multiply every number in an array by 2
I'm trying to find the fastest way to multiply every element in an array by a given number, in this case 2. So far I have written a SIMD instruction that performs at 33 ns multiplying every number in ...
7
votes
2
answers
1k
views
Convert 64-bit Gray code to integer
This algorithm encodes a 64 bit integer.
As input I have a 64 bit integer a, for example:
(a is a single 64 bit number,which I split in 8 bytes for readability) <...
6
votes
3
answers
8k
views
Brute force password cracker in Python
I made a brute force password cracker with Python, but it's extremely slow. How can I make it faster?
...
2
votes
0
answers
316
views
Generic function for interpolating missing values in power query
I have written a (relatively) generic function for interpolating values in power query (also useful for power bi and m code).
I am looking for any improvements or input, but especially:
speed
handle ...
4
votes
3
answers
1k
views
Unbounded, High-performance(?), Generic, Thread-Safe(?), BatchedCircularQueue
This is a data structure I wrote:
It is an circular first-in-first-out queue (a ringbuffer);
It has batched removal/popping - it returns an array of a fixed buffer size;
It is unbounded, and ...
6
votes
1
answer
116
views
One or more planets to line up with the earth a certain amount of times
I have attempted the below question, however my solution is too slow (i.e. It does not fit the 2 second time constrain for java). How can the solution be optimised?
While at IOI 2020 in Singapore, ...
0
votes
0
answers
180
views
Value at Risk forecast generator
I am developing a code to compute Value at Risk (VaR) using various models (see below). Currently, I am looking to implement a rolling window approach over a dataset spanning 4,000 days, with each ...
3
votes
4
answers
1k
views
Merging sorted integer arrays (without duplicates)
I have written a Python function called merge_arrays which takes two lists and returns the new list merge without duplicate.
The function works as expected, but my ...
1
vote
1
answer
179
views
Function that finds the exact number of times a string appears in a text
So I was tasked with providing a function that returns how many exact occurrences of attribute word appear in attribute text. The goal is for the function to be as fast as possible, and I managed to ...
3
votes
1
answer
426
views
Prime factorization algorithm by using the multiprocessing module of Python
I may introduce a Python code of prime factorization which is from my personal project that I'm working on.
...
1
vote
1
answer
95
views
Haskell code optimization for short Pi approximator
Very new in Haskell, as a first easy program I went for an old algorithm of mine to approximate pi by counting points within a circle. The snippet below is what I could get working. I had quite an ...
2
votes
1
answer
76
views
Applying cointegration function from statsmodels on a large dataframe
I need to apply the coint function from the statsmodels library to 207 times series with 1397 points each, two by two.
Currently, it takes between 35-40 minutes on my computer with an Intel 24 Cores ...
1
vote
1
answer
84
views
Code that performs 2500 simulations by running a regression after randomly assigning 10 friends to each observation in a data took 20 days to run
I am running the following code to conduct a simulation. I have a dataset of around 100K observations. The simulation does the following:
It randomly assign 10 "friends" to each observation
...
2
votes
1
answer
118
views
OrderBook Implementation - Follow up
This is a follow up to my previous implementation:
The input is of the format
...
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 ...
5
votes
2
answers
153
views
Get exactly `n` unique randomly sampled rows per category in a Dataframe
I want to get exactly n unique randomly sampled rows per category in a Dataframe. This proved to be involve more steps than the description would lead you to ...