add ruby bench programs and numbers

This commit is contained in:
Torsten Ruger
2015-11-24 15:33:16 +02:00
parent 535757fa98
commit fa63c6db6a
10 changed files with 62 additions and 3 deletions

19
test/bench/ruby/adds.rb Normal file
View File

@ -0,0 +1,19 @@
def fibo( n)
a = 0
b = 1
i = 1
while( i < n ) do
result = a + b
a = b
b = result
i+= 1
end
return result
end
counter = 100000
while(counter > 0) do
fibo(40)
counter -= 1
end

16
test/bench/ruby/calls.rb Normal file
View File

@ -0,0 +1,16 @@
def fibo_r( n )
if( n < 2 )
return n
else
return fibo_r(n - 1) + fibo_r(n - 2)
end
end
counter = 1000
while(counter > 0) do
fibo_r(20)
counter -= 1
end

7
test/bench/ruby/hello.rb Normal file
View File

@ -0,0 +1,7 @@
counter = 100352 - 352;
while(counter > 0) do
puts "Hello there"
STDOUT.flush
counter = counter - 1
end

View File

@ -1,31 +0,0 @@
require_relative '../../soml/helper'
# Benchmarks for the stuff in results.md
module BenchTests
include RuntimeTests
ENV["REMOTE_PI"] = "pi" unless ENV.has_key?("REMOTE_PI")
def setup
@stdout = ""
@machine = Register.machine.boot
Soml::Compiler.load_parfait
end
def main
runko = <<HERE
class Object
int main()
PROGRAM
end
end
HERE
runko.sub("PROGRAM" , @main )
end
def check_remote val
check_r val , true
end
end

8
test/bench/ruby/itos.rb Normal file
View File

@ -0,0 +1,8 @@
counter = 100352 - 352
while(counter > 0) do
str = counter.to_s
counter = counter - 1
end
str

5
test/bench/ruby/loop.rb Normal file
View File

@ -0,0 +1,5 @@
counter = 100000
while(counter > 0) do
counter = counter - 1
end

View File

@ -1,43 +0,0 @@
require_relative 'helper'
class BenchInt < MiniTest::Test
include BenchTests
def test_adds
@main = "int count = 100352 - 352
while_plus( count - 1)
40.fibw( )
count = count - 1
end
return count"
check_remote 0
end
def test_calls
@main = "int count = 1000
while_plus( count - 1)
20.fibr( )
count = count - 1
end
return count"
check_remote 0
end
def test_itos
@main = "int count = 100352 - 352
while_plus( count - 1)
count.to_s( )
count = count - 1
end
return count"
check_remote 0
end
def test_loop
@main = "int count = 100352 - 352
while_plus( count - 1)
count = count - 1
end
return count"
check_remote 0
end
end

View File

@ -1,18 +0,0 @@
require_relative 'helper'
class BenchWord < MiniTest::Test
include BenchTests
def test_hello
@main = <<HERE
int count = 100352 - 352
Word hello = "Hello there"
while_plus( count - 1)
hello.putstring()
count = count - 1
end
return 1
HERE
check_remote 1
end
end