|
Post by aurel on Apr 10, 2022 2:58:07 GMT -6
benchmark your favorite BASIC or similar lang with this small code :
'simple benchmark...o2bas Declare Function GetTickCount Lib "kernel32.dll" () As INT int start,endtime int n float r start = GetTickCount()
for n = 1 to 100000000 r = n*2-sin(88) next n
'endTime = (GetTickCount() - start) / 1000 endTime = GetTickCount() endTime = (endTime - start) / 1000 print "completed in: " + str(endtime) + " seconds"
|
|
|
Post by johnno56 on Apr 10, 2022 4:48:28 GMT -6
QB64 - Did not complete. The for/next loop would not go any higher then 16,777,216 RCBasic - Ran it 3 times. Average of 21.692 seconds SDLBasic - Ran it 3 times. Average of 11.13 seconds
|
|
|
Post by aurel on Apr 10, 2022 8:50:38 GMT -6
QB64 complete it on my computer under win7_32bit in 13 seconds
|
|
|
Post by Tomaaz on Apr 10, 2022 8:54:07 GMT -6
Nim
import math
var r: float64
for n in countup(1, 100000000): r = float64(n * 2) - math.sin(float64(88))
0.882 second on my slow ancient laptop with 2gb RAM. Yeah, I know - "Nim is transpiler blah blah blah..."
tom@bunsenlabs:~/Downloads$ time ./untitled
real 0m0.885s user 0m0.882s sys 0m0.000s
Python 3 takes about 30 sec. I have neither RCBasic or SDLBasic installed on this laptop at the moment. Johnno, can you run this code and let us know how long it takes on your machine?
from math import sin for n in range(1, 100000000): r = n*2-sin(88)
|
|
|
Post by aurel on Apr 10, 2022 9:08:22 GMT -6
tomek you get wrong results like B+ first time with QB64 which is also transpiler then i get properly about 13 seconds ...no way that is 0.88 ..maybe 8 seconds ? for python ,30 second...should be right .
|
|
|
Post by Tomaaz on Apr 10, 2022 9:16:38 GMT -6
It's a correct result. It's getting even better when you compile it with d:release option. The problem here is that you need to modify the program a little bit as the transpiler is trying to optimize the final binary by ignoring the loop that doesn't produce anything useful (by skipping to the last step?) and the whole program takes no time to complete. Here is a modified version:
import math
var r: float64 k: float64
for n in countup(1, 100000000): r = float64(n * 2) - math.sin(float64(88)) k = k + r
This one takes 0.171 second to complete.
|
|
|
Post by aurel on Apr 10, 2022 9:22:05 GMT -6
by the way i cannot run this NIM benchmark because this need C compiler i have it but NIM seems that conot found it even i run finish.exe discard """ action: compile """
#[ ## on osx nim r -d:danger --threads --tlsEmulation:off tests/benchmarks/ttls.nim 9.999999999992654e-07
ditto with `--tlsEmulation:on`: 0.216999 ]#
import times
proc main2(): int = var g0 {.threadvar.}: int g0.inc result = g0
proc main = let n = 100_000_000 var c = 0 let t = cpuTime() for i in 0..<n: c += main2() let t2 = cpuTime() - t doAssert c != 0 echo t2 main() cpuTime ....nice
|
|
|
Post by Tomaaz on Apr 10, 2022 9:22:22 GMT -6
Decided to add one more zero (it's nine of them, instead of eight):
import math
var r: float64 k: float64
for n in countup(1, 1000000000): r = float64(n * 2) - math.sin(float64(88)) k = k + r
Still works and compiled with d:release option takes 1.701 s.
|
|
|
Post by aurel on Apr 10, 2022 9:23:43 GMT -6
exactly and if ignore loop that means that not count time do you really beleive that is sooo faaast ..no is not .
|
|
|
Post by aurel on Apr 10, 2022 9:36:42 GMT -6
hmmm that Nim is interesting really ...is that hard to add simple IDE or editor into windows package? i see that Nim community is not small....then i lurking and found one on github maybe worth a try ..seems nice ? github.com/nim-lang/Aporia
|
|
|
Post by Tomaaz on Apr 10, 2022 9:39:00 GMT -6
Yep, it is. The original program takes 0.002 second, no matter if there is eight zeros or nine zeros (this proves that the loop is ignored). My modified version takes longer for nine zeros what shows you that all calculations are actually done. You can also add echo k at the end of my version and play with the range of the loop. The printed result will be different every time you change the range. It also proves that all the calculations are actually being done.
import math
var r: float64 k: float64
for n in countup(1, 150000000): r = float64(n * 2) - math.sin(float64(88)) k = k + r echo k
Couple of examples:
tom@bunsenlabs:~/Downloads$ time ./untitled 1.010025009949865e+16
real 0m0.179s user 0m0.178s sys 0m0.000s tom@bunsenlabs:~/Downloads$ time ./untitled 225000014488522.9
real 0m0.031s user 0m0.031s sys 0m0.000s tom@bunsenlabs:~/Downloads$ time ./untitled 2.250000013321638e+16
real 0m0.272s user 0m0.254s sys 0m0.004s
|
|
|
Post by aurel on Apr 10, 2022 9:44:57 GMT -6
Look tomek i wont argue with you about this ..simply because it is imposibile so my gues again ..loop is ignored what my posted example give on your machine?
|
|
|
Post by Tomaaz on Apr 10, 2022 10:13:48 GMT -6
Why is this impossible??? If a simple task like this required 5 sec. then there would be no chance to enjoy high quality videos or play modern games. 4k resolution is more than 8 million pixels that need to be calculated, processed, displayed tens of times per second and you want a simple loop with a very basic calculations to run for more than 5 sec.? OK, it has 100 milion steps but come on - do you know the complexity of calculations you need to do while processing compressed video or running a modern game? Take Mandelbrot Set, for example. To generate 1000x1000 pixels picture with good details you need to test each pixel up to several thousand of times (I used 4080), depending on what specific point you're testing. It means that you need to have a loop with more than a billion steps performing more complex calculations than those in your benchmark. I've used Nim for this task and it needed from one to several seconds to generate the picture, depending on which part of Mandelbrot Set I wanted to render. And you want this simple benchmark to take more than that. Seriously?
|
|
|
Post by Tomaaz on Apr 10, 2022 10:28:28 GMT -6
I was wrong. 1 second of 25 fps 4k video means that, every second, you need to calculate, process, display more than... 200 million of pixel which is already a higher number than number of steps in your benchmark. The file needs to be read, information processed, the result sent to graphic buffer... And you expect a simple loop with one line of basic calculation to take more than 5 sec. Right.
|
|
|
Post by johnno56 on Apr 10, 2022 13:20:47 GMT -6
Hmm... I do not understand why, on Windows the benchmark works, but on Linux the loop is limited.... Oh well... Must be a Linux thing... lol
|
|