Skip to content

Commit

Permalink
Add vm_ivar get, get_unitialized, and lazy_set benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
jemmaissroff authored and tenderlove committed Sep 14, 2022
1 parent f98d6d3 commit 513a11b
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 0 deletions.
37 changes: 37 additions & 0 deletions benchmark/vm_ivar_get.yml
@@ -0,0 +1,37 @@
prelude: |
class Example
def initialize
@v0 = 1
@v1 = 2
@v3 = 3
@levar = 1
end
def get_value_loop
sum = 0
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
end
return sum
end
end
obj = Example.new
benchmark:
vm_ivar_get: |
obj.get_value_loop
loop_count: 100
12 changes: 12 additions & 0 deletions benchmark/vm_ivar_get_unintialized.yml
@@ -0,0 +1,12 @@
prelude: |
class Example
def read
@uninitialized
end
end
obj = Example.new
benchmark:
vm_ivar_get_uninitialized: |
obj.read
loop_count: 30000000
12 changes: 12 additions & 0 deletions benchmark/vm_ivar_lazy_set.yml
@@ -0,0 +1,12 @@
prelude: |
class Example
def lazy_set
@uninitialized ||= 123
end
end
objs = 10000000.times.map { Example.new }
benchmark:
vm_ivar_lazy_set: |
objs.each(&:lazy_set)
loop_count: 1

0 comments on commit 513a11b

Please sign in to comment.