Skip to content

Commit b2fa976

Browse files
authored
Add object-new microbenchmark to track allocation performance (#313)
1 parent a0c12c0 commit b2fa976

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

benchmarks.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,10 @@ respond_to:
119119
desc: respond_to tests the performance of the respond_to? method.
120120
category: micro
121121
single_file: true
122+
object-new:
123+
desc: instantiate a new object in a loop to test allocation performance
124+
category: micro
125+
single_file: true
122126
setivar:
123127
desc: setivar tests the performance of setting instance variable values.
124128
category: micro

benchmarks/object-new.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
require_relative '../harness/loader'
2+
3+
run_benchmark(100) do
4+
i = 0
5+
while i < 1_000_000
6+
Object.new
7+
i += 1
8+
end
9+
end

0 commit comments

Comments
 (0)