-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest.rb
More file actions
60 lines (50 loc) · 1018 Bytes
/
test.rb
File metadata and controls
60 lines (50 loc) · 1018 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# Test ruby file for mruby.
def foo()
p 'called foo.'
end
def bar( arg )
p "called bar(#{arg})."
end
def fun( zahl, text, fixzahl )
p "fun(#{zahl}, #{text}, #{fixzahl}"
end
class Klasse
attr_accessor :member_var
def initialize
@member_var = 123
@desc = 'Klasse description'
end
def get_desc
@desc
end
def print
t_printstr @desc
end
def self.bar
p 'called ruby class method'
end
end
# How much time takes the floating point arithmetic in the interpreter?
def loadcpu( num1, num2 )
res = 0.0
(1..1000000).each do |i|
res += num1 / num2 * i
end
res
end
# This w/ a call back to C++ is even slower than the pure ruby one.
def loadcpu2( num1, num2 )
res = 0.0
(1..1000000).each do |i|
res = c_mul_add_add(res, num1, num2,i)
end
res
end
# This is the easy one, just put everything into the C++ call back.
def loadcpu3( num1, num2 )
c_mul_add_add_loop(1000000, num1, num2)
end
p 'In test.rb'
#x = loadcpu 1.5, 23
#puts x
p 'end test.rb'