spl/benchmark.spl

61 lines
1.6 KiB
Text

"#time.spl" import
func main { mega | with args ;
def begin
def end
"[-] spl benchmark v0.1.0" println
"[0] benchmarking while loop with variable 0..100000" println
"==> bgin at " print time:unixms dup =begin println
def i 0 =i
while { i 100000 lt } {
i ++ =i
}
"==> done at " print time:unixms dup =end println
"==> in " print end begin - println
"[1] benchmarking foreach on 100000" println
"==> bgin at " print time:unixms dup =begin println
{ | pop } 100000 :foreach
"==> done at " print time:unixms dup =end println
"==> in " print end begin - println
"[2] benchmarking fast foreach on 100000" println
"==> bgin at " print time:unixms dup =begin println
{ | pop } 100000 :fforeach
"==> done at " print time:unixms dup =end println
"==> in " print end begin - println
"[3] benchmarking foreach on Range 100000..200000" println
"==> bgin at " print time:unixms dup =begin println
100000 200000 Range:new
:iter
:foreach <{ | with i ; }>
"==> done at " print time:unixms dup =end println
"==> in " print end begin - println
"[4] benchmarking manual multiply of 100000 x 5" println
"==> bgin at " print time:unixms dup =begin println
def i 0 =i
def n 0 =n
while { i 100000 lt } {
i ++ =i
n 5 + =n
}
" -> n = " print n println
"==> done at " print time:unixms dup =end println
"==> in " print end begin - println
"[5] benchmarking 10000 array adds" println
"==> bgin at " print time:unixms dup =begin println
def i 0 =i
def arr 0 anew =arr
while { i 10000 lt } {
i awrap arr aadd =arr
i ++ =i
}
"==> done at " print time:unixms dup =end println
"==> in " print end begin - println
0
}