3 ms·
Also make sure you are compiling with optimizations on.
by detrino 12y ago
Also make sure you are compiling with optimizations on.
- geophile 12y agoNow working in an Ubuntu VM, since I know the tools better than I do XCode. I reduced TRIALS to 20, to reduce testing time. I also replaced summation with xor. My current code is here: http://pastebin.com/QcNu2A69 http://pastebin.com/QcNu2A69 Here is what I see with default optimization: jao@minizack:/tmp$ gcc -std=c99 x.c jao@minizack:/tmp$ ./a.out INTERNAL time/scan (usec): 29608.000000 xor: 1722783152 EXTERNAL UNSORTED time/scan (usec): 26688.105263 xor: 1722783152 EXTERNAL SORTED time/scan (usec): 279771.105263 xor: 1722783152 SORTED/UNSORTED: 10.482989 and with -O3: jao@minizack:/tmp$ gcc -std=c99 -O3 x.c jao@minizack:/tmp$ ./a.out INTERNAL time/scan (usec): 3636.421053 xor: 1722783152 EXTERNAL UNSORTED time/scan (usec): 12114.263158 xor: 1722783152 EXTERNAL SORTED time/scan (usec): 242141.263158 xor: 1722783152 SORTED/UNSORTED: 19.988113 The INTERNAL time is 8x faster. EXTERNAL UNSORTED is 2x faster. EXTERNAL SORTED hasn't sped up much at all. My conclusions: - With -O3, the difference between INTERNAL (#1) and EXTERNAL UNSORTED (#2) is close to what you are seeing. - Loops cannot be optimized away in this version. - The fact that -O3 speeds up EXTERNAL UNSORTED by 2x but EXTERNAL SORTED only a little makes sense if the latter is slow due to cache misses.
- detrino 12y agoWell, benchmarking without optimizations enabled isn't very useful :)