QB64.org Forum

Active Forums => Programs => Topic started by: bplus on April 10, 2022, 01:55:11 pm

Title: Benchmark_01
Post by: bplus on April 10, 2022, 01:55:11 pm
Can someone verify this code is correct and it takes under .5 secs to run, Aurel doesn't believe it.
http://basic4all.epizy.com/index.php?topic=21.0

Code: QB64: [Select]
  1. start = Timer(.001)
  2. For n = 1 To 100000000
  3.     r = n * 2 - Sin(88)
  4. Next n&
  5. Print Timer(.001) - start; "seconds"
  6.  

 


BTW oddly it does better with Double than with Single default.
Title: Re: Benchmark_01
Post by: jack on April 10, 2022, 02:31:04 pm
it times at .25 seconds on my PC
but as a benchmark it's lame, a good compiler will eliminate the loop entirely and therefore give a meaningless result
Title: Re: Benchmark_01
Post by: bplus on April 10, 2022, 02:44:58 pm
Thank you Jack! Keybonic Plague also gets way better time than I with optimized QB64 dev 2.1

I know it's lame I didn't make it up just comparing times with other PL's and Basic's.

So I didn't screw up, it's possible to get under .5 secs.
Title: Re: Benchmark_01
Post by: jack on April 10, 2022, 02:51:32 pm
I meant no offense to you bplus, I know who came up with the code
but if you want to do a benchmark you need to do some computations that can't be optimized out and print the result for verification
Title: Re: Benchmark_01
Post by: Richard Frost on April 10, 2022, 10:10:00 pm
4.07s on my ancient machine.