News for hackers. Stuff that matters.
Re:Yet Another Language Speed Test – Counting Primes by x0054 on Saturday July 04, 2015 @12:54AM (#9829269)
This test is rather misleading. For instance, I decided to rewrite this same procedure in Swift. I was stunned to find out that at first the speed was almost 4 times slower. The C program took 34 seconds to run to 67108864 while Swift took 2:11 minutes.

However, after swapping out the Float only capable square root from Swift Foundation for the C sqrt function, leaving the rest of the code identical, the execution time on the Swift code went down to 35 seconds, basically identical.

I have to wonder if Python, Ruby, and PHP just have a Float only capable square root function, or handle numbers with much higher precision than necessary by the test.

Re:Yet Another Language Speed Test – Counting Primes by caf on Saturday July 04, 2015 @12:57AM (#9829277)
The C sqrt function is

  double sqrt(double)
Re:Yet Another Language Speed Test – Counting Primes by x0054 on Saturday July 04, 2015 @01:03AM (#9829293)
Hmm, I can see that too now, though I am passing into it a CInt, and getting back a CInt. Is it just converting the Int to Double internally and shooting back a Double which is converted to CInt? If so, why do you think it's so much faster?