2022-09-14 23:48:40 +03:00
|
|
|
prelude: |
|
|
|
|
class Example
|
2022-09-15 03:39:39 +03:00
|
|
|
def initialize
|
|
|
|
@v0 = 1
|
|
|
|
@v1 = 2
|
|
|
|
@v3 = 3
|
|
|
|
@levar = 1
|
|
|
|
end
|
2022-09-14 23:48:40 +03:00
|
|
|
|
2022-09-15 03:39:39 +03:00
|
|
|
def get_value_loop
|
|
|
|
sum = 0
|
2022-09-14 23:48:40 +03:00
|
|
|
|
2022-09-15 03:39:39 +03:00
|
|
|
i = 0
|
|
|
|
while i < 1000000
|
|
|
|
# 10 times to de-emphasize loop overhead
|
|
|
|
sum += @levar
|
|
|
|
sum += @levar
|
|
|
|
sum += @levar
|
|
|
|
sum += @levar
|
|
|
|
sum += @levar
|
|
|
|
sum += @levar
|
|
|
|
sum += @levar
|
|
|
|
sum += @levar
|
|
|
|
sum += @levar
|
|
|
|
sum += @levar
|
|
|
|
i += 1
|
2022-09-14 23:48:40 +03:00
|
|
|
end
|
2022-09-15 03:39:39 +03:00
|
|
|
|
|
|
|
return sum
|
|
|
|
end
|
2022-09-14 23:48:40 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
obj = Example.new
|
|
|
|
benchmark:
|
|
|
|
vm_ivar_get: |
|
|
|
|
obj.get_value_loop
|
|
|
|
loop_count: 100
|