some speed improvements, make fforeach more useful

This commit is contained in:
Daniella / Tove 2024-09-10 11:01:21 +02:00
parent 15ae8622e1
commit fd41c46cdd
2 changed files with 15 additions and 15 deletions

View file

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

View file

@ -8,11 +8,11 @@ def program-name
def print'pre-std &print =print'pre-std def print'pre-std &print =print'pre-std
func print { | func print { |
_str print'pre-std call _str !!- print'pre-std inline-callable
} }
func println { | func println { |
!!- _str "\n" concat print _str !!- "\n" concat print
} }
construct error { construct error {
@ -121,7 +121,7 @@ construct _mega-ext {
while { !!- i this lt } { !!- i callable call i 1 + =i } while { !!- i this lt } { !!- i callable call i 1 + =i }
} }
fforeach { | with callable this ; fforeach { | with callable this ;
0 while { !!- dup2 this lt } { !!- callable inline-callable 1 + } 0 while { !!- dup2 this lt } { !!- callable call 1 + }
} }
} include _mega-ext in mega } include _mega-ext in mega