Merge branch 'master' into new_mom
This commit is contained in:
@ -1,5 +1,3 @@
|
||||
#include<stdio.h>
|
||||
|
||||
int fibo(int n){
|
||||
int result;
|
||||
int a = 0;
|
||||
@ -17,11 +15,10 @@ int fibo(int n){
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int counter = 100352 - 352;
|
||||
int counter2 = counter;
|
||||
int level = 40;
|
||||
int counter = 50000;
|
||||
int fib ;
|
||||
while(counter--) {
|
||||
fib = fibo(level);
|
||||
while(counter) {
|
||||
fib = fibo(40);
|
||||
counter -= 1;
|
||||
}
|
||||
}
|
||||
|
@ -10,10 +10,9 @@ int fibo_r(int n)
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int counter = 1000;
|
||||
int counter2 = counter;
|
||||
int counter = 100;
|
||||
int fib ;
|
||||
while(counter--) {
|
||||
fib = fibo_r(20);
|
||||
fib += fibo_r(20);
|
||||
}
|
||||
}
|
||||
|
@ -2,8 +2,8 @@
|
||||
|
||||
int main(void)
|
||||
{
|
||||
setbuf(stdout, NULL); /* to make it equivalent to the typed version, otherwise it caches */
|
||||
int counter = 100352 - 352;
|
||||
setbuf(stdout, NULL); /* to make it equivalent to the other versions, otherwise it caches */
|
||||
int counter = 10000;
|
||||
while(counter--) {
|
||||
printf("Hello there\n");
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,9 +1,7 @@
|
||||
#include<stdio.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int counter = 100352 - 352;
|
||||
while(counter) {
|
||||
counter = counter - 1;
|
||||
}
|
||||
int counter = 1000000;
|
||||
while(counter) {
|
||||
counter -= 1;
|
||||
}
|
||||
}
|
||||
|
5
test/bench/c/noop.c
Normal file
5
test/bench/c/noop.c
Normal file
@ -0,0 +1,5 @@
|
||||
|
||||
int main(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
@ -18,8 +18,10 @@ func fibo(n int ) int {
|
||||
|
||||
func main() {
|
||||
sum := 1
|
||||
for sum < 100000 {
|
||||
res := 0
|
||||
for sum < 50000 {
|
||||
sum += 1
|
||||
fibo( 40 )
|
||||
res = fibo( 40 )
|
||||
}
|
||||
res += 1
|
||||
}
|
@ -10,7 +10,7 @@ func fib(n uint) uint {
|
||||
|
||||
func main() {
|
||||
sum := 1
|
||||
for sum < 1000 {
|
||||
for sum < 100 {
|
||||
sum += 1
|
||||
fib( 20 )
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ import "fmt"
|
||||
|
||||
func main() {
|
||||
sum := 1
|
||||
for sum < 100000 {
|
||||
for sum < 10000 {
|
||||
sum += 1
|
||||
fmt.Println("Hi there")
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ package main
|
||||
|
||||
func main() {
|
||||
sum := 1
|
||||
for sum < 100000 {
|
||||
for sum < 1000000 {
|
||||
sum += 1
|
||||
}
|
||||
}
|
||||
|
5
test/bench/go/noop.go
Normal file
5
test/bench/go/noop.go
Normal file
@ -0,0 +1,5 @@
|
||||
package main
|
||||
|
||||
func main() {
|
||||
return
|
||||
}
|
@ -1,36 +1,30 @@
|
||||
# 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
|
||||
hello - output hello world to measure kernel calls
|
||||
add - run integer adds by linear fibonacci of 40
|
||||
call - exercise calling by recursive fibonacci of 20
|
||||
noop - a baseline that does nothing
|
||||
loop - just counts down, from 1M
|
||||
|
||||
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
|
||||
Loop, Hello, add and call run 1M , 50k, 10k and 100 respectively,
|
||||
to minimize startup impact.
|
||||
|
||||
Gcc used to compile c on the machine
|
||||
typed produced by ruby (on another machine)
|
||||
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.
|
||||
Also output was unbuffered, because that is what rubyx implements.
|
||||
|
||||
# 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 somewhere from 1M to 100, depending on how intensive.
|
||||
|
||||
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.
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
language | noop | hello | add | call | loop
|
||||
c | 55 | 380 | 88 | 135 | 6
|
||||
go | 52 | 450 | 9 | 77 | 2
|
||||
rubyx | 42 | 200 | 1700 | 1700 | 480
|
||||
ruby | 1570 | 650 | 1090 | 1500 | 180
|
||||
mruby | 86 | 1200 | 1370 | 2700 | 300
|
||||
|
@ -11,7 +11,7 @@ def fibo( n)
|
||||
return result
|
||||
end
|
||||
|
||||
counter = 100000
|
||||
counter = 50000
|
||||
|
||||
while(counter > 0) do
|
||||
fibo(40)
|
||||
|
@ -8,7 +8,7 @@ def fibo_r( n )
|
||||
end
|
||||
|
||||
|
||||
counter = 1000
|
||||
counter = 100
|
||||
|
||||
while(counter > 0) do
|
||||
fibo_r(20)
|
||||
|
@ -1,7 +1,8 @@
|
||||
|
||||
counter = 100352 - 352;
|
||||
counter = 10000;
|
||||
while(counter > 0) do
|
||||
puts "Hello there"
|
||||
# roughly 4 times slower with this, which is like rubyx
|
||||
STDOUT.flush
|
||||
counter = counter - 1
|
||||
end
|
||||
|
@ -1,5 +1,5 @@
|
||||
|
||||
counter = 100000
|
||||
counter = 1000000
|
||||
while(counter > 0) do
|
||||
counter = counter - 1
|
||||
counter -= 1
|
||||
end
|
||||
|
1
test/bench/ruby/noop.rb
Normal file
1
test/bench/ruby/noop.rb
Normal file
@ -0,0 +1 @@
|
||||
return 0
|
26
test/bench/rubyx/adds.rb
Normal file
26
test/bench/rubyx/adds.rb
Normal file
@ -0,0 +1,26 @@
|
||||
class Space
|
||||
|
||||
def fibo_i(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
|
||||
end
|
||||
|
||||
# ran with --parfait=80000
|
||||
def main(arg)
|
||||
b = 1000
|
||||
while( b >= 1 )
|
||||
b = b - 1
|
||||
fibo_i(40)
|
||||
end
|
||||
return b
|
||||
end
|
||||
end
|
22
test/bench/rubyx/calls.rb
Normal file
22
test/bench/rubyx/calls.rb
Normal file
@ -0,0 +1,22 @@
|
||||
class Space
|
||||
|
||||
def fibo_r( n )
|
||||
if( n < 2 )
|
||||
return n
|
||||
end
|
||||
a = fibo_r(n - 1)
|
||||
b = fibo_r(n - 2)
|
||||
return a + b
|
||||
end
|
||||
|
||||
# ran with --parfait=70000
|
||||
def main(arg)
|
||||
b = 2
|
||||
res = 0
|
||||
while( b >= 1 )
|
||||
b = b - 1
|
||||
res = fibo_r(20)
|
||||
end
|
||||
return res
|
||||
end
|
||||
end
|
11
test/bench/rubyx/hello.rb
Normal file
11
test/bench/rubyx/hello.rb
Normal file
@ -0,0 +1,11 @@
|
||||
class Space
|
||||
# ran with --parfait=25000
|
||||
def main(arg)
|
||||
b = 10000
|
||||
while( b >= 1 )
|
||||
b = b - 1
|
||||
"Hello-there\n".putstring
|
||||
end
|
||||
return b
|
||||
end
|
||||
end
|
11
test/bench/rubyx/loop.rb
Normal file
11
test/bench/rubyx/loop.rb
Normal file
@ -0,0 +1,11 @@
|
||||
class Space
|
||||
|
||||
# ran with --parfait=101000
|
||||
def main(arg)
|
||||
b = 100000
|
||||
while( b >= 1 )
|
||||
b = b - 1
|
||||
end
|
||||
return b
|
||||
end
|
||||
end
|
5
test/bench/rubyx/noop.rb
Normal file
5
test/bench/rubyx/noop.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class Space
|
||||
def main(arg)
|
||||
return 0
|
||||
end
|
||||
end
|
@ -17,7 +17,7 @@ class Stats
|
||||
def show
|
||||
#puts "no per var"
|
||||
|
||||
puts "#{@n} #{@mean} #{@variance / @n}"
|
||||
puts "#{@n} #{(@mean*1000).truncate(1)} #{((@variance / @n)*100).truncate(2)}"
|
||||
end
|
||||
end
|
||||
class Runner
|
||||
|
@ -13,3 +13,4 @@ class Space
|
||||
return result
|
||||
end
|
||||
end
|
||||
#Space.new.main(1)
|
||||
|
@ -11,7 +11,7 @@ module Risc
|
||||
|
||||
def test_simple_collect
|
||||
objects = Collector.collect_space(@linker)
|
||||
assert ((400 < objects.length) or (450 > objects.length)) , objects.length.to_s
|
||||
assert_equal 600 , objects.length , objects.length.to_s
|
||||
end
|
||||
|
||||
def test_collect_all_types
|
||||
@ -34,5 +34,40 @@ module Risc
|
||||
assert !position.valid?
|
||||
end
|
||||
end
|
||||
def test_integer_positions
|
||||
objects = Collector.collect_space(@linker)
|
||||
int = Parfait.object_space.get_next_for(:Integer)
|
||||
while(int)
|
||||
assert Position.set?(int) , "INt #{int.object_id}"
|
||||
int = int.next_integer
|
||||
end
|
||||
end
|
||||
end
|
||||
class TestBigCollector < MiniTest::Test
|
||||
|
||||
def setup
|
||||
opt = Parfait.default_test_options
|
||||
opt[:factory] = 4000
|
||||
Parfait.boot!(opt)
|
||||
Risc.boot!
|
||||
@linker = Mom::MomCompiler.new.translate(:arm)
|
||||
end
|
||||
|
||||
def test_simple_collect
|
||||
objects = Collector.collect_space(@linker)
|
||||
assert_equal 20329, objects.length , objects.length.to_s
|
||||
end
|
||||
|
||||
def test_integer_positions
|
||||
objects = Collector.collect_space(@linker)
|
||||
int = Parfait.object_space.get_next_for(:Integer)
|
||||
count = 0
|
||||
while(int)
|
||||
count += 1
|
||||
assert Position.set?(int) , "INT #{int.object_id} , count #{count}"
|
||||
int = int.next_integer
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user