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.
7,649
questions
0
votes
2
answers
30
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
24
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 -...
1
vote
0
answers
71
views
Python integer optimization with PuLP 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
1
answer
29
views
Print a hollow Rhombus [closed]
I am beginner in java, here is my code to print a hollow rhombus:
...
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 ...
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 ...
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 ...
4
votes
2
answers
437
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:
...
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 ...
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 ...
3
votes
2
answers
265
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 ...
1
vote
5
answers
173
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
0
answers
152
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 ...
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
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 ...
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 ...
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.
...
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
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
66
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.
...
3
votes
1
answer
218
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 ...
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 ...
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) <...
4
votes
1
answer
132
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] ...
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 ...
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 ...
1
vote
1
answer
94
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
118
views
OrderBook Implementation - Follow up
This is a follow up to my previous implementation:
The input is of the format
...
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 ...
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
...
1
vote
0
answers
79
views
Electro-thermal simulation
I'm working on an electro-thermal simulation with variable parameters.
Model require the calculation of all the electrical and thermal quantities at each time step, between a starting and ending time. ...
2
votes
1
answer
39
views
Implementing an improved merge sort that uses insertion sort, with "levels" - Would this work correctly?
We were asked to improve the merge sort algorithm by introducing insertion sort to the code. We have been tasked with doing this by utilising a "levels" logic. Here is the exact description ...
2
votes
0
answers
29
views
Inputting a list of unique numbers in Scratch
So I am working on recreating a hidden minigame from PvZ Brutal Mode EX+/Unnamed Mod in Scratch for fun here. While I am making some considerable progress on it, I'm having trouble simplifying the ...
3
votes
3
answers
192
views
Extracting records from a 2D List of strings
Recently I had an interview question about extracting records that matched certain criteria from a 2D List of strings. The premise was a CSV file was parsed into a ...
6
votes
1
answer
135
views
Exponentiation in Scratch
This was back when I was new to coding on Scratch (as in the case of coding projects entirely from scratch) around 7-8 months ago with my Cookie Clicker in Scratch project that I made pretty much ...
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 ...
1
vote
1
answer
95
views
considering only the instants of trading with the relative price avoiding stale returns
in my MATLAB code I describe a model for price formation with stale returns
in this framework there are 2 type of trader: informed traders who always trade in the "right direction" and noise ...
0
votes
0
answers
145
views
3D Game Engine Using Turtle
I am making a 3d Game Engine named t3d using Python's turtle module. Here is the code:
...
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, ...
11
votes
2
answers
2k
views
Faster chess engine in python (with move ordering algorithm?)
I, an amateur coder, have been trying to code a chess engine with python as part of a larger research project. I started by following this tutorial (turns out creator of said tutorial has a github of ...
2
votes
0
answers
29
views
Efficient code to move a node under another while keeping all HierarchyId's as integers and sequential
I'm playing around with an app that will need to read Hierarchy trees quickly but will seldom modify them once created. I've chosen to use HierarchyIds with Entity Framework to model the hierarchy. I ...
1
vote
1
answer
97
views
Leetcode: Maximum score from performing multiplication operations
I am looking for feedback on how to make my code more performant (take less time) - specifically with a top-down approach.
My specific asks are:
How can I make this code faster? It currently takes ...
1
vote
1
answer
51
views
Find all combinations of two companies grouped by the projects they are tendering for
I am working on the task to get all possible combinations (pairs) of ID's (companies) which participated in one bid and create a new data frame with ID_1, ID_2, matching parameter (tender ID).
I have ...
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
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 ...
0
votes
0
answers
35
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 ...