Commit 4e2092a7

4e2092a74656Merged

Yukihiro "Matz" Matsumoto <[email protected]> · 8 months ago · 2 files · +2 added

Description

Port structaref/structaset benchmarks

Both Struct getter/setter benchmarks work out of the box. structaref: Spinel <0.01s vs CRuby 0.21s (>21x) structaset: Spinel <0.01s vs CRuby (similar) 79/79 tests pass.

Co-Authored-By: Claude Opus 4.6 (1M context) [email protected]

Details

Commit
4e2092a74656
Parent
8f49d73a7e78

examples/bm_structaref.rbaddedView file

1+# structaref benchmark (from yjit-bench)
2+TheClass = Struct.new(:v0, :v1, :v2, :levar)
3+
4+def get_value_loop(obj)
5+ sum = 0
6+ i = 0
7+ while i < 1000000
8+ sum = sum + obj.levar
9+ sum = sum + obj.levar
10+ sum = sum + obj.levar
11+ sum = sum + obj.levar
12+ sum = sum + obj.levar
13+ sum = sum + obj.levar
14+ sum = sum + obj.levar
15+ sum = sum + obj.levar
16+ sum = sum + obj.levar
17+ sum = sum + obj.levar
18+ i = i + 1
19+ end
20+ sum
21+end
22+
23+obj = TheClass.new(1, 2, 3, 1)
24+puts get_value_loop(obj)
25+puts "done"