Search Results
Search type | Search syntax |
---|---|
Tags | [tag] |
Exact | "words here" |
Author |
user:1234 user:me (yours) |
Score |
score:3 (3+) score:0 (none) |
Answers |
answers:3 (3+) answers:0 (none) isaccepted:yes hasaccepted:no inquestion:1234 |
Views | views:250 |
Code | code:"if (foo != bar)" |
Sections |
title:apples body:"apples oranges" |
URL | url:"*.example.com" |
Saves | in:saves |
Status |
closed:yes duplicate:no migrated:no wiki:no |
Types |
is:question is:answer |
Exclude |
-[tag] -apples |
For more details on advanced search visit our help page |
Performance is a subset of Optimization: performance is the goal when you want the execution time of your program or routine to be optimal.
3
votes
Accepted
Addition or Subtraction Calculator that Processes Up to 15 Operands
Here are some things that may help you improve your code.
Eliminate "magic numbers"
Instead of hard-coding the constants such as 3, 48 and 55 in the code, it would be better to use a #define or const …
4
votes
Accepted
Finding the longest word without these characters
fp)) {
perror("couldn't read file");
free(buffer);
return 1;
}
// rest of program here
free(buffer);
}
Consider using standard library functions
At a very small performance … Consider using pointers
There may not be a performance difference in this case, but for problems like these, the use of pointers seems more natural to me. …
3
votes
Accepted
Distance between two different sets of points
Avoiding the habit of using std::endl when '\n' will do will pay dividends in the future as you write more complex programs with more I/O and where performance needs to be maximized. …
8
votes
Accepted
How to make Project Euler 32 in Python faster?
Since you know that all of the non-zero digits must be present in the answer, you can skip most of the numbers in the range. That is, it's pointless to do a test multiplication of 22*3333 because tho …
5
votes
Accepted
32-bit factorial calculator in x86 NASM assembly
There might be a slight performance advantage to replicating the code multiple times via a macro invocation, but more often, it just leads to code bloat. …
10
votes
Efficient algorithm for counting frequency of a numbers in intervals
I see a number of things that could help you improve your code.
Don't abuse using namespace std
Putting using namespace std at the top of every program is a bad habit that you'd do well to avoid. K …
1
vote
Faster Sudoku solver in C
There are a number of things that could be improved in this code.
Post complete code
I understand that this code was migrated from Stack Overflow where the rules are a little different, but here on …
4
votes
Finding the sum of all the segment counts of a 7-segment display in a range
Here are some things that may help you improve your program. First, I'll mention a few things about the code you've already written, and then I'll describe an idea for a better algorithm.
Be careful …
2
votes
Circular Buffer in C - Follow Up
I see some things that may help you improve your code.
Use all of the required #includes
The macro SIZE_MAX is used but its declaration is in #include <stdint.h> (not <stdlib.h>) which is not actual …
8
votes
Accepted
Test four int of commonality in the lower four bits
The code isn't bad, but it's a little more verbose than it needs to be. Consider that we don't really need to check one bit at a time; we can check four simultaneously.
The key here is that we're lo …
2
votes
Accepted
Find the modal value of a sample of numbers
Here are some ideas to help you improve your code, and perhaps inspire you to learn more.
Reconsider using
The code currently contains these two lines:
using std::cout;
using std::cin;
That's not too …
5
votes
Accepted
Getting all possible letter combinations of a word
I see some things that may help you improve your code.
Consider separating input and output
Right now, the unscramble function does both the permutation and the printing of both outputs and errors. …
1
vote
Striping a matrix concentrically, anticlockwise
Minimize system calls
If you're looking for performance, it's often a good idea to avoid system calls, such as for malloc. …
7
votes
Accepted
Improving function that replaces all instances of x with y in string
Unless you really need the stream flushed, you can improve the performance of the code by simply emitting '\n' instead of using the potentially more computationally costly std::endl. …
4
votes
Accepted
C Hash table implementation
before and after any changes
As with the test function above, you should write many different test functions for your hash and measure their performance. … It's only by actually measuring before and after any change that you will be able to tell for certain whether you are improving or worsening the performance. …