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:
parent
28836457c5
commit
96972dab29
@ -105,6 +105,7 @@ class Integer < Value
|
||||
|
||||
Word to_s()
|
||||
Word start = " "
|
||||
start.set_length(0)
|
||||
return as_string( start )
|
||||
end
|
||||
|
||||
|
@ -17,13 +17,11 @@ int fibo(int n){
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int counter = 1000000;
|
||||
int counter = 98304 + 1696;
|
||||
int counter2 = counter;
|
||||
int level = 40;
|
||||
int fib ;
|
||||
while(counter--) {
|
||||
fib = fibo(level);
|
||||
}
|
||||
printf("%i times fib %d \n",counter2 , level);
|
||||
|
||||
}
|
19
test/bench/calls.c
Normal file
19
test/bench/calls.c
Normal 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);
|
||||
}
|
||||
}
|
@ -2,7 +2,7 @@
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int counter = 1000000;
|
||||
int counter = 98304 + 1696;
|
||||
while(counter--) {
|
||||
printf("Hello there\n");
|
||||
}
|
||||
|
@ -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
11
test/bench/itos.c
Normal 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);
|
||||
}
|
||||
}
|
@ -2,5 +2,8 @@
|
||||
|
||||
int main(void)
|
||||
{
|
||||
return 1;
|
||||
int counter = 98304 + 1696;
|
||||
while(counter--) {
|
||||
counter = counter;
|
||||
}
|
||||
}
|
||||
|
@ -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
28
test/bench/results.md
Normal 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
|
@ -16,7 +16,8 @@ class Stats
|
||||
end
|
||||
def show
|
||||
#puts "no per var"
|
||||
puts "#{@n} #{@mean} #{@variance}"
|
||||
|
||||
puts "#{@n} #{@mean} #{@variance / @n}"
|
||||
end
|
||||
end
|
||||
class Runner
|
||||
@ -25,12 +26,14 @@ class Runner
|
||||
@cmd = ARGV[0]
|
||||
end
|
||||
def run
|
||||
{ once } while true
|
||||
while true
|
||||
once
|
||||
end
|
||||
end
|
||||
|
||||
def once
|
||||
GC.disable
|
||||
took = Benchmark.measure { %x("#{@cmd}")}.real
|
||||
took = Benchmark.measure { %x(#{@cmd} > /dev/null)}.real
|
||||
GC.enable
|
||||
@stats.add took
|
||||
@stats.show
|
||||
|
@ -29,6 +29,8 @@ module RuntimeTests
|
||||
|
||||
def check ret = nil
|
||||
load_program
|
||||
check_remote ret
|
||||
exit
|
||||
interpreter = Register::Interpreter.new
|
||||
interpreter.start @machine.init
|
||||
count = 0
|
||||
@ -59,9 +61,9 @@ module RuntimeTests
|
||||
return unless box = connected
|
||||
load_program
|
||||
file = write_object_file
|
||||
print "\nfile #{file} "
|
||||
r_file = file.sub("./" , "salama/")
|
||||
box.file_upload file , r_file
|
||||
print "\nfile #{file} "
|
||||
box.ld "-N", r_file
|
||||
begin #need to rescue here as rye throws if no return 0
|
||||
ret = box.aout # and we use return to mean something
|
||||
|
@ -179,6 +179,15 @@ five.putstring()"
|
||||
@stdout = " 21"
|
||||
check 21
|
||||
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
|
||||
@main = "int fib = 8.fibw( )
|
||||
@ -193,9 +202,8 @@ five.putstring()"
|
||||
check 6765
|
||||
end
|
||||
|
||||
def pest_fib40_1000000
|
||||
@main = "int count = 999424
|
||||
count = count + 576
|
||||
def test_fib40_100000
|
||||
@main = "int count = 100352 - 352
|
||||
while_plus( count - 1)
|
||||
40.fibw( )
|
||||
count = count - 1
|
||||
@ -203,4 +211,21 @@ five.putstring()"
|
||||
return count"
|
||||
check 0
|
||||
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
|
||||
|
@ -177,4 +177,17 @@ return w.char_length
|
||||
HERE
|
||||
check 4
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user