3 ms·
Sadly the data is useless without the exact compiler flags. I get 18.0658 with default "g++ PrimeChecker.c -o PrimeChecker" and 11.7689 with "g++ PrimeChecker.
by madisp 11y ago
Sadly the data is useless without the exact compiler flags.
I get 18.0658 with default "g++ PrimeChecker.c -o PrimeChecker" and 11.7689 with "g++ PrimeChecker.c -O2 -o PrimeChecker"
edit: the hardware is an i7-4870HQ, quite close to the i7-4850HQ that's in the blogpost (+200MHz clock)
- vmorgulis 11y agoHere is my results on a desktop PC from 2010 (i3 CPU 540 @ 3.07GHz × 4): g++ -O3 -o prime PrimeChecker.c time ./prime 9592 primes between 0 and 100000 Time taken = 18.0476 real 0m18.073s user 0m18.048s sys 0m0.000s It seems the Moore's Law is no longer valid...
- gambiting 11y agoWell I've tried an even older machine - a 2009 MacBook Pro with a 2.4GHz Core2Duo. g++ PrimeChecker.c -o PrimeChecker: Time taken = 26.2687 g++ PrimeChecker.c -O2 -o PrimeChecker: Time taken = 21.6129 So I would say that this his test doesn't really prove anything, not with an operation as simple as finding primes.
- B1FF_PSUVM 11y agoWell, that kind of numbers is why I'm tossing 200 bucks worth of RAM and SSD at my 2009 machine, instead of getting the new shiny. (Although the new shiny is indeed pretty - I'll confess to almost drooling at http://www.macrumors.com/roundup/retina-macbook-air/ http://www.macrumors.com/roundup/retina-macbook-air/ ;-)
- maccard 11y agoI'm running an i7-6700k, on Windows 10 with the MSVC 2015 compiler, my results were 9592 primes between 0 and 100000 Time taken = 12.808 Without optimisations, and 9592 primes between 0 and 100000 Time taken = 10.853 with full optimisations. I would ahve thought it would have been much better. without and with optimisations.
- bithush 11y agoIt is wasting a lot of time with the pointless bool assignments. See my post below.
- maccard 11y agoBut then I'm not running the same code as either the parent of my comment, or the article, and the benchmark doesn't hold. It's how fast can my CPU run the same code vs theres. I could make it faster again by precomputing a table and doing a lookup but that defies the point!
- bithush 11y agoVery good point. I was just surprised how much that simple bool assignment slowed things down so massively.
- maccard 11y agoI started at 10.853, and with very little effort brought it down to 0.003 The slowdown isn't in assigning the bool; If you pass in 10000000 into that function, it's going to get isPrime set to true on the first iteration, but if you early out, you save all of those values. Again, this isn't really the point of the exercise, it's supposed to be comparing the performance of the same piece of code ran on different hardware. https://gist.github.com/anonymous/c6d5bae04334cbc7ef9583ebb7faf587 https://gist.github.com/anonymous/c6d5bae04334cbc7ef9583ebb7...
- deleted 11y ago[deleted]