Skip to content

Commit

Permalink
Add object-new microbenchmark to track allocation performance (#313)
Browse files Browse the repository at this point in the history
  • Loading branch information
maximecb authored Jul 25, 2024
1 parent a0c12c0 commit b2fa976
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ respond_to:
desc: respond_to tests the performance of the respond_to? method.
category: micro
single_file: true
object-new:
desc: instantiate a new object in a loop to test allocation performance
category: micro
single_file: true
setivar:
desc: setivar tests the performance of setting instance variable values.
category: micro
Expand Down
9 changes: 9 additions & 0 deletions benchmarks/object-new.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
require_relative '../harness/loader'

run_benchmark(100) do
i = 0
while i < 1_000_000
Object.new
i += 1
end
end

0 comments on commit b2fa976

Please sign in to comment.