diff --git a/test/bench/c/adds.c b/test/bench/c/adds.c index abbb964f..082af906 100644 --- a/test/bench/c/adds.c +++ b/test/bench/c/adds.c @@ -17,11 +17,10 @@ int fibo(int n){ int main(void) { - int counter = 100352 - 352; - int counter2 = counter; - int level = 40; + int counter = 100000; int fib ; - while(counter--) { - fib = fibo(level); + while(counter) { + fib += fibo(20); + counter -= 1; } } diff --git a/test/bench/c/calls.c b/test/bench/c/calls.c index 08c8f68f..934a0049 100644 --- a/test/bench/c/calls.c +++ b/test/bench/c/calls.c @@ -10,10 +10,9 @@ int fibo_r(int n) int main(void) { - int counter = 1000; - int counter2 = counter; + int counter = 100000; int fib ; while(counter--) { - fib = fibo_r(20); + fib += fibo_r(10); } } diff --git a/test/bench/c/hello.c b/test/bench/c/hello.c index 49eddd74..f3323d27 100644 --- a/test/bench/c/hello.c +++ b/test/bench/c/hello.c @@ -2,8 +2,7 @@ int main(void) { - setbuf(stdout, NULL); /* to make it equivalent to the typed version, otherwise it caches */ - int counter = 100352 - 352; + int counter = 100000; while(counter--) { printf("Hello there\n"); } diff --git a/test/bench/c/itos.c b/test/bench/c/itos.c index 830032f9..2ad66b41 100644 --- a/test/bench/c/itos.c +++ b/test/bench/c/itos.c @@ -3,9 +3,9 @@ int main(void) { char stringa[20] ; - - int counter = 100352 - 352; + int counter = 1000; while(counter--) { - sprintf(stringa, "%i\n" , counter); + sprintf(stringa, "%i\n" , counter); } + } diff --git a/test/bench/c/loop.c b/test/bench/c/loop.c deleted file mode 100644 index d055b57d..00000000 --- a/test/bench/c/loop.c +++ /dev/null @@ -1,9 +0,0 @@ -#include - -int main(void) -{ -int counter = 100352 - 352; - while(counter) { - counter = counter - 1; - } -} diff --git a/test/bench/c/noop.c b/test/bench/c/noop.c new file mode 100644 index 00000000..402eac33 --- /dev/null +++ b/test/bench/c/noop.c @@ -0,0 +1,5 @@ + +int main(void) +{ + return 0; +} diff --git a/test/bench/go/add.go b/test/bench/go/adds.go similarity index 94% rename from test/bench/go/add.go rename to test/bench/go/adds.go index 35129e0d..93f26cda 100644 --- a/test/bench/go/add.go +++ b/test/bench/go/adds.go @@ -20,6 +20,6 @@ func main() { sum := 1 for sum < 100000 { sum += 1 - fibo( 40 ) + fibo( 20 ) } } diff --git a/test/bench/go/calls.go b/test/bench/go/calls.go index 847279f8..978380e8 100644 --- a/test/bench/go/calls.go +++ b/test/bench/go/calls.go @@ -10,8 +10,8 @@ func fib(n uint) uint { func main() { sum := 1 - for sum < 1000 { + for sum < 100000 { sum += 1 - fib( 20 ) + fib( 10 ) } } diff --git a/test/bench/go/noop.go b/test/bench/go/noop.go new file mode 100644 index 00000000..b563617c --- /dev/null +++ b/test/bench/go/noop.go @@ -0,0 +1,5 @@ +package main + +func main() { + return +} diff --git a/test/bench/results.md b/test/bench/results.md index ef9a160d..464aefdc 100644 --- a/test/bench/results.md +++ b/test/bench/results.md @@ -1,36 +1,28 @@ # Benchmarks -loop - program does empty loop of same size as hello -hello - output hello world (to dev/null) to measure kernel calls (not terminal speed) -itos - convert integers from 1 to 100000 to string -add - run integer adds by linear fibonacci of 40 -call - exercise calling by recursive fibonacci of 20 +hello - output hello world to measure kernel calls +add - run integer adds by linear fibonacci of 20 +call - exercise calling by recursive fibonacci of 10 +noop - a baseline that does nothing -Hello and puti and add run 100_000 iterations per program invocation to remove startup overhead. -Call only has 10000 iterations, as it much slower - -Gcc used to compile c on the machine -typed produced by ruby (on another machine) +All programs (apart from noop) run 1M times to minimize startup impact. +C was linked statically as dynamic linked influences times. Output was sent to /dev/null, so as +to measure the calling and not the terminal. # Results Results were measured by a ruby script. Mean and variance was measured until variance was low, -always under one percent. +always under one percent. Noop showed that program startup is a factor, so all programs loop to 1M. -The machine was a virtual arm run on a powerbook, performance roughly equivalent to a raspberry pi. -But results should be seen as relative, not absolute. +The machine was a virtual arm (qemu) run on a acer swift 5 (i5 8265 3.9GHz), performance roughly equivalent to a raspberry pi. +But results (in ms) should be seen as relative, not absolute. -language | loop | hello | itos | add | call -c | 0,0500 | 2,1365 | 0,2902 | 0,1245 | 0,8535 -go | 0.0485 | 4.5355 | 0.2143 | 0.0825 | 0.8769 -typed | 0,0374 | 1,2071 | 0,7263 | 0,2247 | 1,3625 +language | noop | hello | add | call +c | 45 | 100 | 72 | 591 +go | 53 | 4060 | 64 | 624 +rubyx | 0,0374 | 1,2071 | 0,2247 | 1,3625 -ruby | 0,3 | 8.882 | 0,8971 | 3,8452 - -2c | - 33 % | - 79 % | + 150% | + 80 % | + 60 % - -2r | x 10 | x 6 | + 23% | x 17 | x 26 +ruby | 1830 | 2750 | 3000 | 1900_000 Comparison with ruby, not really for speed, just to see how much leeway there is for our next layer. -Ruby startup time is 1,5695 seconds, which we'll subtract from the benches diff --git a/test/bench/ruby/adds.rb b/test/bench/ruby/adds.rb index b4fb2b02..bb58be11 100644 --- a/test/bench/ruby/adds.rb +++ b/test/bench/ruby/adds.rb @@ -14,6 +14,6 @@ end counter = 100000 while(counter > 0) do - fibo(40) + fibo(20) counter -= 1 end diff --git a/test/bench/ruby/calls.rb b/test/bench/ruby/calls.rb index 1b1274e7..3ba39352 100644 --- a/test/bench/ruby/calls.rb +++ b/test/bench/ruby/calls.rb @@ -8,9 +8,9 @@ def fibo_r( n ) end - counter = 1000 + counter = 100 while(counter > 0) do - fibo_r(20) + fibo_r(10) counter -= 1 end diff --git a/test/bench/ruby/hello.rb b/test/bench/ruby/hello.rb index a7e30f7c..d730117a 100644 --- a/test/bench/ruby/hello.rb +++ b/test/bench/ruby/hello.rb @@ -1,7 +1,6 @@ -counter = 100352 - 352; +counter = 100000; while(counter > 0) do puts "Hello there" - STDOUT.flush counter = counter - 1 end diff --git a/test/bench/ruby/noop.rb b/test/bench/ruby/noop.rb new file mode 100644 index 00000000..61c7ebff --- /dev/null +++ b/test/bench/ruby/noop.rb @@ -0,0 +1 @@ +return 0 diff --git a/test/mains/source/fibo__8.rb b/test/mains/source/fibo__8.rb index 70f8aa58..871b3099 100644 --- a/test/mains/source/fibo__8.rb +++ b/test/mains/source/fibo__8.rb @@ -1,6 +1,6 @@ class Space def main(arg) - n = 6 + n = 10 a = 0 b = 1 i = 1 @@ -13,3 +13,4 @@ class Space return result end end +#Space.new.main(1) diff --git a/test/mains/source/puts_Hello-there_11.rb b/test/mains/source/puts_Hello-there_11.rb index 59dcf17c..0d901ae2 100644 --- a/test/mains/source/puts_Hello-there_11.rb +++ b/test/mains/source/puts_Hello-there_11.rb @@ -1,5 +1,5 @@ class Space def main(arg) - return "Hello-there".putstring + return "Hello-there\n".putstring end end diff --git a/test/mains/source/recurse-fibo__5.rb b/test/mains/source/recurse-fibo__5.rb index cbcab0f4..3515a135 100644 --- a/test/mains/source/recurse-fibo__5.rb +++ b/test/mains/source/recurse-fibo__5.rb @@ -11,6 +11,6 @@ class Space end def main(arg) - return fibo_r(5) + return fibo_r(10) end end