add simple loop bench
fiddled with run numbers a bit recording times with noop removed results slightly worse than hoped
This commit is contained in:
parent
8eb0ba0d81
commit
6b1c316f04
@ -1,5 +1,3 @@
|
|||||||
#include<stdio.h>
|
|
||||||
|
|
||||||
int fibo(int n){
|
int fibo(int n){
|
||||||
int result;
|
int result;
|
||||||
int a = 0;
|
int a = 0;
|
||||||
@ -17,10 +15,10 @@ int fibo(int n){
|
|||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
int counter = 100000;
|
int counter = 50000;
|
||||||
int fib ;
|
int fib ;
|
||||||
while(counter) {
|
while(counter) {
|
||||||
fib += fibo(20);
|
fib = fibo(40);
|
||||||
counter -= 1;
|
counter -= 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ int fibo_r(int n)
|
|||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
int counter = 1000;
|
int counter = 100;
|
||||||
int fib ;
|
int fib ;
|
||||||
while(counter--) {
|
while(counter--) {
|
||||||
fib += fibo_r(20);
|
fib += fibo_r(20);
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
setbuf(stdout, NULL); /* to make it equivalent to the other versions, otherwise it caches */
|
setbuf(stdout, NULL); /* to make it equivalent to the other versions, otherwise it caches */
|
||||||
int counter = 100000;
|
int counter = 10000;
|
||||||
while(counter--) {
|
while(counter--) {
|
||||||
printf("Hello there\n");
|
printf("Hello there\n");
|
||||||
}
|
}
|
||||||
|
7
test/bench/c/loop.c
Normal file
7
test/bench/c/loop.c
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
int counter = 1000000;
|
||||||
|
while(counter) {
|
||||||
|
counter -= 1;
|
||||||
|
}
|
||||||
|
}
|
@ -18,8 +18,10 @@ func fibo(n int ) int {
|
|||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
sum := 1
|
sum := 1
|
||||||
for sum < 100000 {
|
res := 0
|
||||||
|
for sum < 50000 {
|
||||||
sum += 1
|
sum += 1
|
||||||
fibo( 20 )
|
res = fibo( 40 )
|
||||||
}
|
}
|
||||||
|
res += 1
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ func fib(n uint) uint {
|
|||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
sum := 1
|
sum := 1
|
||||||
for sum < 1000 {
|
for sum < 100 {
|
||||||
sum += 1
|
sum += 1
|
||||||
fib( 20 )
|
fib( 20 )
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ import "fmt"
|
|||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
sum := 1
|
sum := 1
|
||||||
for sum < 100000 {
|
for sum < 10000 {
|
||||||
sum += 1
|
sum += 1
|
||||||
fmt.Println("Hi there")
|
fmt.Println("Hi there")
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@ package main
|
|||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
sum := 1
|
sum := 1
|
||||||
for sum < 100000 {
|
for sum < 1000000 {
|
||||||
sum += 1
|
sum += 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
# Benchmarks
|
# Benchmarks
|
||||||
|
|
||||||
hello - output hello world to measure kernel calls
|
hello - output hello world to measure kernel calls
|
||||||
add - run integer adds by linear fibonacci of 20
|
add - run integer adds by linear fibonacci of 40
|
||||||
call - exercise calling by recursive fibonacci of 20
|
call - exercise calling by recursive fibonacci of 20
|
||||||
noop - a baseline that does nothing
|
noop - a baseline that does nothing
|
||||||
|
loop - just counts down, from 1M
|
||||||
|
|
||||||
Hello and add run 100k times, calls 1k, to minimize startup impact.
|
Loop, Hello, add and call run 1M , 50k, 10k and 100 respectively,
|
||||||
|
to minimize startup impact.
|
||||||
|
|
||||||
C was linked statically as dynamic linked influences times.
|
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.
|
Output was sent to /dev/null, so as to measure the calling and not the terminal.
|
||||||
@ -14,16 +16,15 @@ Also output was unbuffered, because that is what rubyx implements.
|
|||||||
# Results
|
# Results
|
||||||
|
|
||||||
Results were measured by a ruby script. Mean and variance was measured until variance was low,
|
Results were measured by a ruby script. Mean and variance was measured until variance was low,
|
||||||
always under one percent. Noop showed that program startup is a factor, so all programs loop
|
always under one percent. Noop showed that program startup is a factor, so all programs loop from 10 to 50k.
|
||||||
to 100k.
|
|
||||||
|
|
||||||
The machine was a virtual arm (qemu) run on a acer swift 5 (i5 8265 3.9GHz), performance roughly equivalent to a raspberry pi.
|
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.
|
Results (in ms) should be seen as relative, not absolute.
|
||||||
|
|
||||||
|
|
||||||
language | noop | hello | add | call
|
language | noop | hello | add | call | loop
|
||||||
c | 45 | 3480 | 150 | 1400
|
c | 55 | 380 | 88 | 135 | 6
|
||||||
go | 53 | 4000 | 64 | 740
|
go | 52 | 450 | 9 | 77 | 2
|
||||||
rubyx | 43 | 1560 | 1800 | 16500
|
rubyx | 42 | 200 | 1700 | 1700 | 480
|
||||||
ruby | 1570 | 8240 | 2290 | 17800
|
ruby | 1570 | 650 | 1090 | 1500 | 180
|
||||||
mruby | 86 | 11210 | 1580 | 26500
|
mruby | 86 | 1200 | 1370 | 2700 | 300
|
||||||
|
@ -11,9 +11,9 @@ def fibo( n)
|
|||||||
return result
|
return result
|
||||||
end
|
end
|
||||||
|
|
||||||
counter = 100000
|
counter = 50000
|
||||||
|
|
||||||
while(counter > 0) do
|
while(counter > 0) do
|
||||||
fibo(20)
|
fibo(40)
|
||||||
counter -= 1
|
counter -= 1
|
||||||
end
|
end
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
|
|
||||||
counter = 100000;
|
counter = 10000;
|
||||||
while(counter > 0) do
|
while(counter > 0) do
|
||||||
puts "Hello there"
|
puts "Hello there"
|
||||||
# roughly 4 times slower with this, which is like rubyx
|
# roughly 4 times slower with this, which is like rubyx
|
||||||
#STDOUT.flush
|
STDOUT.flush
|
||||||
counter = counter - 1
|
counter = counter - 1
|
||||||
end
|
end
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
counter = 100000
|
counter = 1000000
|
||||||
while(counter > 0) do
|
while(counter > 0) do
|
||||||
counter = counter - 1
|
counter -= 1
|
||||||
end
|
end
|
||||||
|
@ -14,12 +14,12 @@ class Space
|
|||||||
return result
|
return result
|
||||||
end
|
end
|
||||||
|
|
||||||
# ran with --parfait=40000
|
# ran with --parfait=80000
|
||||||
def main(arg)
|
def main(arg)
|
||||||
b = 1000
|
b = 1000
|
||||||
while( b >= 1 )
|
while( b >= 1 )
|
||||||
b = b - 1
|
b = b - 1
|
||||||
fibo_i(20)
|
fibo_i(40)
|
||||||
end
|
end
|
||||||
return b
|
return b
|
||||||
end
|
end
|
||||||
|
@ -5,8 +5,8 @@ class Space
|
|||||||
return n
|
return n
|
||||||
end
|
end
|
||||||
a = fibo_r(n - 1)
|
a = fibo_r(n - 1)
|
||||||
d = fibo_r(n - 2)
|
b = fibo_r(n - 2)
|
||||||
return a + d
|
return a + b
|
||||||
end
|
end
|
||||||
|
|
||||||
# ran with --parfait=70000
|
# ran with --parfait=70000
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
class Space
|
class Space
|
||||||
# ran with --parfait=25000
|
# ran with --parfait=25000
|
||||||
# time - noop * 10 + noop
|
|
||||||
def main(arg)
|
def main(arg)
|
||||||
b = 10000
|
b = 10000
|
||||||
while( b >= 1 )
|
while( b >= 1 )
|
||||||
|
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
|
@ -17,7 +17,7 @@ class Stats
|
|||||||
def show
|
def show
|
||||||
#puts "no per var"
|
#puts "no per var"
|
||||||
|
|
||||||
puts "#{@n} #{@mean} #{@variance / @n}"
|
puts "#{@n} #{(@mean*1000).truncate(1)} #{((@variance / @n)*100).truncate(2)}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
class Runner
|
class Runner
|
||||||
|
Loading…
Reference in New Issue
Block a user