From 8eb0ba0d8108f749070f21f2e8a259f71bbaa685 Mon Sep 17 00:00:00 2001 From: Torsten Date: Tue, 30 Jul 2019 21:16:24 +0300 Subject: [PATCH] fix benchmarks up to 20 recursive fibo had mixed add and calls for rubyx --- test/bench/c/calls.c | 4 ++-- test/bench/go/calls.go | 4 ++-- test/bench/results.md | 14 +++++++------- test/bench/ruby/calls.rb | 4 ++-- test/bench/rubyx/adds.rb | 19 +++++++++++-------- test/bench/rubyx/calls.rb | 29 ++++++++++++----------------- 6 files changed, 36 insertions(+), 38 deletions(-) diff --git a/test/bench/c/calls.c b/test/bench/c/calls.c index 934a0049..afd751ce 100644 --- a/test/bench/c/calls.c +++ b/test/bench/c/calls.c @@ -10,9 +10,9 @@ int fibo_r(int n) int main(void) { - int counter = 100000; + int counter = 1000; int fib ; while(counter--) { - fib += fibo_r(10); + fib += fibo_r(20); } } diff --git a/test/bench/go/calls.go b/test/bench/go/calls.go index 978380e8..847279f8 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 < 100000 { + for sum < 1000 { sum += 1 - fib( 10 ) + fib( 20 ) } } diff --git a/test/bench/results.md b/test/bench/results.md index 74339043..5c93dc85 100644 --- a/test/bench/results.md +++ b/test/bench/results.md @@ -2,10 +2,10 @@ 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 +call - exercise calling by recursive fibonacci of 20 noop - a baseline that does nothing -All programs (apart from noop) run 100k times to minimize startup impact. +Hello and add run 100k times, calls 1k, 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. @@ -22,8 +22,8 @@ Results (in ms) should be seen as relative, not absolute. language | noop | hello | add | call -c | 45 | 3480 | 72 | 591 -go | 53 | 4000 | 64 | 624 -rubyx | 47 | 1660 | 800 | 2000 -ruby | 1570 | 8240 | 2700 | 12370 -mruby | 108 | 11210 | 1580 | 23400 +c | 45 | 3480 | 150 | 1400 +go | 53 | 4000 | 64 | 740 +rubyx | 43 | 1560 | 1800 | 16500 +ruby | 1570 | 8240 | 2290 | 17800 +mruby | 86 | 11210 | 1580 | 26500 diff --git a/test/bench/ruby/calls.rb b/test/bench/ruby/calls.rb index 93a16379..a3aa2c4c 100644 --- a/test/bench/ruby/calls.rb +++ b/test/bench/ruby/calls.rb @@ -8,9 +8,9 @@ def fibo_r( n ) end - counter = 10000 + counter = 100 while(counter > 0) do - fibo_r(10) + fibo_r(20) counter -= 1 end diff --git a/test/bench/rubyx/adds.rb b/test/bench/rubyx/adds.rb index e293e95a..2519f5d6 100644 --- a/test/bench/rubyx/adds.rb +++ b/test/bench/rubyx/adds.rb @@ -1,19 +1,22 @@ class Space def fibo_i(fib) + n = fib a = 0 - b = fib - while( a < b ) - a = a + 1 - b = b - 1 + b = 1 + i = 1 + while( i < n ) + result = a + b + a = b + b = result + i = i + 1 end - return a + return result end - # ran with --parfait=100000 - # (time - noop) * 25 + noop + # ran with --parfait=40000 def main(arg) - b = 4000 + b = 1000 while( b >= 1 ) b = b - 1 fibo_i(20) diff --git a/test/bench/rubyx/calls.rb b/test/bench/rubyx/calls.rb index 813d1ef5..3a6693c7 100644 --- a/test/bench/rubyx/calls.rb +++ b/test/bench/rubyx/calls.rb @@ -1,27 +1,22 @@ class Space - def fibo_r(fib) - n = fib - a = 0 - b = 1 - i = 1 - while( i < n ) - result = a + b - a = b - b = result - i = i + 1 - end - return result + def fibo_r( n ) + if( n < 2 ) + return n + end + a = fibo_r(n - 1) + d = fibo_r(n - 2) + return a + d end - # ran with --parfait=80000 - # (time - noop) * 50 + noop + # ran with --parfait=70000 def main(arg) - b = 2000 + b = 2 + res = 0 while( b >= 1 ) b = b - 1 - fibo_r(20) + res = fibo_r(20) end - return b + return res end end