Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add vm_ivar get, get_unitialized, and lazy_set benchmarks
- Loading branch information
1 parent
f98d6d3
commit 513a11b
Showing
3 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |