moved all the ruby benches out of the tests
here into bench dir and a little frame
This commit is contained in:
parent
f865486f1e
commit
1e2b784583
31
test/bench/ruby/helper.rb
Normal file
31
test/bench/ruby/helper.rb
Normal file
@ -0,0 +1,31 @@
|
||||
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
|
43
test/bench/ruby/test_integer.rb
Normal file
43
test/bench/ruby/test_integer.rb
Normal file
@ -0,0 +1,43 @@
|
||||
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
|
18
test/bench/ruby/test_word.rb
Normal file
18
test/bench/ruby/test_word.rb
Normal file
@ -0,0 +1,18 @@
|
||||
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
|
@ -29,7 +29,7 @@ module RuntimeTests
|
||||
|
||||
def check ret = nil
|
||||
i = check_local
|
||||
check_remote ret
|
||||
check_r ret
|
||||
i
|
||||
end
|
||||
|
||||
@ -60,13 +60,14 @@ module RuntimeTests
|
||||
@@conn = Rye::Box.new(machine || "localhost" , :port => (port || 2222) , :user => (user || "pi"))
|
||||
end
|
||||
|
||||
def check_remote ret_val
|
||||
def check_r ret_val , dont_run = false
|
||||
return unless box = connected
|
||||
load_program
|
||||
file = write_object_file
|
||||
r_file = file.sub("./" , "salama/")
|
||||
box.file_upload file , r_file
|
||||
print "\nfile #{file} "
|
||||
return if dont_run
|
||||
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user