New answers tagged performance
2votes
Slow SQL query with nested subquery
The inner select has a max to much. I think that is meant to do less time conversions, or such. But it clashes with group by. ...
3votes
Accepted
Solution to the N Queens Puzzle in the PicoBlaze assembly language
Glad to learn that you got the correct result, but 3 hours is still a long time for this, I think. Luckily, there are lots of opportunities for optimizing this program. A lot of copying is going on ...
2votes
Simulation of a mechanical arm
1. Encapsulate your “nearest-neighbor” logic You repeat the same block of code six times: ...
2votes
Finding Special Parts in a Word
In such code, one should look for rules, smart logic. Here we have sequences x² and xyⁿx. (As already said in an earlier answer, with n = 0 one covers the first sequence.) The logic here is detecting ...
4votes
4votes
Finding Special Parts in a Word
The "length 2" rule is unnecessary, just ignore it and read the "length ≥ 3" rule as "length ≥ 2" instead. You can simplify your code accordingly, removing the ...
-2votes
Finding Special Parts in a Word
To reduce time complexity, we can avoid redundant substring operations and take advantage of string patterns. This strategy aims to solve the problem efficiently, with a time complexity closer to O(n²)...
1vote
Butter side up?
When working with Mathematica, performance optimization is crucial for handling complex computations efficiently. One key improvement is using FindRoot instead of NSolve for numerical problems. ...
15votes
Accepted
CUDA Mandelbrot Kernel
Small issues Avoid doing calculations that the CPU can do. For example, let the CPU calculate scale_factor and pass it in as an argument. Then you also don't need <...
1vote
Divide a set into subset with some constraints
Your implementation has extremely severe superlinear time blowup. Comparing your implementation to one I'll describe momentarily, here are some rudimentary benchmark comparisons: ...
1vote
Divide a set into subset with some constraints
Here are some minor coding style suggestions. They are not likely to improve performance. Documentation Add a docstring for the min_count function to describe its ...
2votes
Lotto simulator in Python
Documentation The PEP 8 style guide recommends adding docstrings for functions. You should also add a docstring to the top of the code to summarize its purpose. For example: ...
3votes
Accepted
SIFT Keypoint Detection for Image in C++
Avoid repeating yourself Code duplication increases the maintenance burden and the chance of introducing bugs. Try to avoid it as much as possible. For exampe, in ...
1vote
3votes
Simple chess engine
Constants Use underscore characters to make large numeric literals easier to read and understand. For example, change: 0xFF000000000000 to: ...
2votes
Fibonacci Sequence Generator generates 1 million numbers
One of my big learning in programming was that the most elegant is not always the fastest. If you need to frequently calculate big Fibonacci numbers, the fastest way is probably to hard code some of ...
1vote
Random forest code algorithm
Documentation The PEP 8 style guide recommends adding docstrings for files and functions. For example, for the data_load.py file, since "data" is a ...
3votes
Accepted
LeetCode Number 416: Partition Equal Subset Sum
Performance Since your primary concern is mem/runtime, let's address this first. Your algorithm appears correct, but is missing one small optimization: laziness. You always traverse both branches to <...
2votes
Binance.Net getting historical data from start date to end date loop optimization
Whale's Secret ScriptApiLib allows you to do get candlesticks without implementing it yourself. The library takes into accounts these implementation details like that the most you can get in one ...
10votes
Fibonacci Sequence Generator generates 1 million numbers
Iteration variable The most obvious change is that the iteration variable itself doesn't need to be a BigInteger. A simple int, ...
10votes
Fibonacci Sequence Generator generates 1 million numbers
Caveat: I don't work with C# (or with its BigInteger facilities) meaning this "answer" is speculative, noting the use of 3 variables and several transfer operations during each of a million ...
2votes
LeetCode Number 416: Partition Equal Subset Sum
The following only applies to your code (with the find method), not the dfs LeetCode example. I can not think of a way to ...
5votes
Accepted
Julias Set fractal timelapse
Use a vector math library You can almost halve the number of lines of code if you use a vector math library. These allow you to avoid calculating x and y coordinates separately, and instead provide ...
9votes
How to implement an AVL tree efficient enough in Haskell?
As I said in a comment, I can't verify that your program as written uses 40MB - your profiling data and my own runs of your program show 3MB, in the same range as the C++ performance you refer to. ...
3votes
Accepted
Efficiently simulating a control sequence
I really need to make it as fast as possible. Does anybody have any suggestions/tips/tricks to speed up this code? Make a test harness Form test code that rates the performance and precision ...
2votes
2D line-of-sight recalculation code causes lag whenever a door is opened
restartable calculation Together, this is 52ms, which means there is a visible lag of 4 frames whenever a door opens. Relax what the definition of "correct" is. Animate the door, gradually ...
3votes
Store special deals, like 3 for 2
Note This question was posted 5+ years ago. Using Python 2 today is not recommended. However, it can still be reviewed. There are 2 major things here that stand out, the calculation and the printing ...

Mast♦
- 13.7k
Top 50 recent answers are included
Related Tags
performance × 9109python × 2362
java × 1273
c++ × 1103
algorithm × 1004
c# × 870
javascript × 838
programming-challenge × 648
python-3.x × 646
beginner × 624
c × 551
strings × 375
array × 327
php × 297
vba × 271
excel × 270
sql × 258
numpy × 243
primes × 220
jquery × 206
image × 198
multithreading × 181
python-2.x × 181
matrix × 179
recursion × 156