Skip to content
Merged
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
4 changes: 4 additions & 0 deletions benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,10 @@ str_concat:
category: micro
single_file: true
ractor: true
struct-new-no-escape:
desc: instantiate new struct objects with fields in a loop to test allocation and escape analysis performance
category: micro
single_file: true
structaref:
desc: structaref tests the performance of getting Struct members
category: micro
Expand Down
16 changes: 16 additions & 0 deletions benchmarks/struct-new-no-escape.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
require_relative '../harness/loader'

Point = Struct.new(:x, :y)

def test
p = Point.new(1, 2)
p.x + p.y
end

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