thats most of the benchmarking

strange about the puts in soml, hard to see where a factor of 10 would
come from
This commit is contained in:
Torsten Ruger 2015-11-20 23:51:58 +02:00
parent 28836457c5
commit 96972dab29
13 changed files with 115 additions and 30 deletions

View File

@ -105,6 +105,7 @@ class Integer < Value
Word to_s() Word to_s()
Word start = " " Word start = " "
start.set_length(0)
return as_string( start ) return as_string( start )
end end

View File

@ -17,13 +17,11 @@ int fibo(int n){
int main(void) int main(void)
{ {
int counter = 1000000; int counter = 98304 + 1696;
int counter2 = counter; int counter2 = counter;
int level = 40; int level = 40;
int fib ; int fib ;
while(counter--) { while(counter--) {
fib = fibo(level); fib = fibo(level);
} }
printf("%i times fib %d \n",counter2 , level);
} }

19
test/bench/calls.c Normal file
View File

@ -0,0 +1,19 @@
#include<stdio.h>
int fibo_r(int n)
{
if ( n < 2 )
return n;
else
return ( fibo_r(n-1) + fibo_r(n-2) );
}
int main(void)
{
int counter = 1000;
int counter2 = counter;
int fib ;
while(counter--) {
fib = fibo_r(20);
}
}

View File

@ -2,7 +2,7 @@
int main(void) int main(void)
{ {
int counter = 1000000; int counter = 98304 + 1696;
while(counter--) { while(counter--) {
printf("Hello there\n"); printf("Hello there\n");
} }

View File

@ -1,9 +0,0 @@
#include<stdio.h>
int main(void)
{
int counter = 1000000;
while(counter--) {
printf("Hello there\n");
}
}

11
test/bench/itos.c Normal file
View File

@ -0,0 +1,11 @@
#include<stdio.h>
int main(void)
{
char stringa[20] ;
int counter = 98304 + 1696;
while(counter--) {
sprintf(stringa, "%i\n" , counter);
}
}

View File

@ -2,5 +2,8 @@
int main(void) int main(void)
{ {
return 1; int counter = 98304 + 1696;
while(counter--) {
counter = counter;
}
} }

View File

@ -1,9 +0,0 @@
#include<stdio.h>
int main(void)
{
int counter = 1000000;
while(counter--) {
printf("%i\n" , counter);
}
}

28
test/bench/results.md Normal file
View File

@ -0,0 +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 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
soml produced by ruby (on another machine)
# Results
Results were measured by a ruby script. Mean and variance was measured until variance was low,
usually under one percent.
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.
language | loop | hello | itos | add | call
c | 0.1530 | 0.3422 | 0.871 | 0.3968 | 2.5913
c variance| 0.0018  | 0.010 | 0.027 | 0.0013 | 0.0058
soml | 0.1130 | 3.5778 | 3.772 | 0.6856 | 4.0325
variance | 0.0009 | 0.021 | 0.001 | 0.0014 | 0.0035

View File

@ -16,7 +16,8 @@ class Stats
end end
def show def show
#puts "no per var" #puts "no per var"
puts "#{@n} #{@mean} #{@variance}"
puts "#{@n} #{@mean} #{@variance / @n}"
end end
end end
class Runner class Runner
@ -25,12 +26,14 @@ class Runner
@cmd = ARGV[0] @cmd = ARGV[0]
end end
def run def run
{ once } while true while true
once
end
end end
def once def once
GC.disable GC.disable
took = Benchmark.measure { %x("#{@cmd}")}.real took = Benchmark.measure { %x(#{@cmd} > /dev/null)}.real
GC.enable GC.enable
@stats.add took @stats.add took
@stats.show @stats.show

View File

@ -29,6 +29,8 @@ module RuntimeTests
def check ret = nil def check ret = nil
load_program load_program
check_remote ret
exit
interpreter = Register::Interpreter.new interpreter = Register::Interpreter.new
interpreter.start @machine.init interpreter.start @machine.init
count = 0 count = 0
@ -59,9 +61,9 @@ module RuntimeTests
return unless box = connected return unless box = connected
load_program load_program
file = write_object_file file = write_object_file
print "\nfile #{file} "
r_file = file.sub("./" , "salama/") r_file = file.sub("./" , "salama/")
box.file_upload file , r_file box.file_upload file , r_file
print "\nfile #{file} "
box.ld "-N", r_file box.ld "-N", r_file
begin #need to rescue here as rye throws if no return 0 begin #need to rescue here as rye throws if no return 0
ret = box.aout # and we use return to mean something ret = box.aout # and we use return to mean something

View File

@ -179,6 +179,15 @@ five.putstring()"
@stdout = " 21" @stdout = " 21"
check 21 check 21
end end
def test_fib20_1000
@main = "int count = 1000
while_plus( count - 1)
20.fibr( )
count = count - 1
end
return count"
check 0
end
def test_fibw8 def test_fibw8
@main = "int fib = 8.fibw( ) @main = "int fib = 8.fibw( )
@ -193,9 +202,8 @@ five.putstring()"
check 6765 check 6765
end end
def pest_fib40_1000000 def test_fib40_100000
@main = "int count = 999424 @main = "int count = 100352 - 352
count = count + 576
while_plus( count - 1) while_plus( count - 1)
40.fibw( ) 40.fibw( )
count = count - 1 count = count - 1
@ -203,4 +211,21 @@ five.putstring()"
return count" return count"
check 0 check 0
end end
def test_itos_100000
@main = "int count = 100352 - 352
while_plus( count - 1)
count.to_s( )
count = count - 1
end
return count"
check 0
end
def test_loop_100000
@main = "int count = 100352 - 352
while_plus( count - 1)
count = count - 1
end
return count"
check 0
end
end end

View File

@ -177,4 +177,17 @@ return w.char_length
HERE HERE
check 4 check 4
end end
def test_puts_100000
@main = <<HERE
int count = 100352 - 352
Word hello = "Hello there"
while_plus( count - 1)
hello.putstring()
count = count - 1
end
return 1
HERE
check 1
end
end end