Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,11 @@ object-new:
category: micro
single_file: true
ractor: true
object-new-ivars:
desc: instantiate a new object with ivars in a loop to test allocation and escape analysis performance
category: micro
single_file: true
ractor: true
respond_to:
desc: respond_to tests the performance of the respond_to? method.
category: micro
Expand Down
25 changes: 25 additions & 0 deletions benchmarks/object-new-ivars.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
require_relative '../harness/loader'

class Point
attr_reader :x, :y
def initialize(x, y)
@x = x
@y = y
end

def ==(other)
@x == other.x && @y == other.y
end
end

def test
Point.new(1, 2) == Point.new(1, 2)
end

run_benchmark(100) do
i = 0
while i < 1_000_000
test
i += 1
end
end
Loading