Closed GregorDeCillia closed 9 years ago
Interesting. The following two code snippets result in identical assembler code (obtained with g++ -S
). I wonder where the speedup comes from.
1.
#include <stddef.h>
int main() {
int j = 0;
for (size_t i(0); i < 10; ++i) ++j;
}
2.
#include <stddef.h>
int main() {
int j = 0;
for (size_t i = 0; i < 10; ++i) ++j;
}
I was also kind of suprised that these changes made a difference. My tests used g++
with the Ofast
flag as well as the boost_unit_test
framework.
Indeed quite surprising. You would think that this wouldnt make any difference to the compiler compiler...
May I ask how much of a performance improvement this gives? I would like to also check on the intel compiler before doing this merge.
srange. i just created a simpler test case and created two assembly files one with and one without my commit and there does not seem to be any difference.
i guess i should have done more testing before creating a pull request. thanks for pointing that out @ddemidov
@mariomulansky please close this pull request. there is probably a problem with my test case
While testing, i found that replacing
by
in
array_algebra.hpp
gives a better performance for the state typesboost::array
andstd::array
.I also replaced these loops on other parts of the code just in case there are similar performance impacts.