2022-09-14 16:48:40 -04:00
|
|
|
prelude: |
|
|
|
|
class Example
|
2022-09-14 20:39:39 -04:00
|
|
|
def initialize
|
|
|
|
@v0 = 1
|
|
|
|
@v1 = 2
|
|
|
|
@v3 = 3
|
|
|
|
@levar = 1
|
|
|
|
end
|
2022-09-14 16:48:40 -04:00
|
|
|
|
2022-09-14 20:39:39 -04:00
|
|
|
def get_value_loop
|
|
|
|
sum = 0
|
2022-09-14 16:48:40 -04:00
|
|
|
|
2022-09-14 20:39:39 -04: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 16:48:40 -04:00
|
|
|
end
|
2022-09-14 20:39:39 -04:00
|
|
|
|
|
|
|
return sum
|
|
|
|
end
|
2022-09-14 16:48:40 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
obj = Example.new
|
|
|
|
benchmark:
|
|
|
|
vm_ivar_get: |
|
|
|
|
obj.get_value_loop
|
|
|
|
loop_count: 100
|