2 ms·
The -O2 flag wasn't added to the benchmark script until Sept 20th in commit 4a31931, I suspect you ran at least sum.c without that flag since any modern gcc com
by Johnny555 10y ago
The -O2 flag wasn't added to the benchmark script until Sept 20th in commit 4a31931, I suspect you ran at least sum.c without that flag since any modern gcc compiler should have optimized away that entire loop.
I downloaded and ran the benchmarks and indeed the search for the 1 second runtime for sum.c never completed -- it never found an answer because the sum binary runs in constant time regardless of the iteration count. In fact, atoi() in sum.c quickly overflowed once the iteration count exceeded 2^31 (since atoi() returns a signed int). I removed the -O2 flag and then I got the same 550429840 iter count as you on my laptop.
The benchmark script isn't really doing a binary search, it's doing a linear search since it's increasing the iteration count by 10% with each loop.