diff options
| author | Aaron Patterson <tenderlove@ruby-lang.org> | 2024-07-03 11:40:56 -0700 |
|---|---|---|
| committer | Aaron Patterson <aaron.patterson@gmail.com> | 2024-07-03 12:32:53 -0700 |
| commit | b974c84606535d8f58addc5ab2ceb6d3ea827d15 (patch) | |
| tree | c34c39dc09bc9bf226dc7379202892c71aa74318 /test/ruby | |
| parent | 6ac05ddb8abf7c01996dd7ea6a8c90bab2692604 (diff) | |
Move Array#map to Ruby
Improves activerecord by about 1% on the interpreter:
```
before: ruby 3.4.0dev (2024-07-03T18:40:10Z master f88841b8f3) [arm64-darwin23]
after: ruby 3.4.0dev (2024-07-03T18:41:14Z ruby-map 6c0df4eb32) [arm64-darwin23]
------------ ----------- ---------- ---------- ---------- ------------- ------------
bench before (ms) stddev (%) after (ms) stddev (%) after 1st itr before/after
activerecord 235.2 0.8 233.6 0.7 1.01 1.01
------------ ----------- ---------- ---------- ---------- ------------- ------------
Legend:
- after 1st itr: ratio of before/after time for the first benchmarking iteration.
- before/after: ratio of before/after time. Higher is better for after. Above 1 represents a speedup.
```
Improves YJIT by about 4%:
```
before: ruby 3.4.0dev (2024-07-03T18:40:10Z master f88841b8f3) +YJIT [arm64-darwin23]
after: ruby 3.4.0dev (2024-07-03T18:41:14Z ruby-map 6c0df4eb32) +YJIT [arm64-darwin23]
------------ ----------- ---------- ---------- ---------- ------------- ------------
bench before (ms) stddev (%) after (ms) stddev (%) after 1st itr before/after
activerecord 142.1 1.2 137.0 0.6 1.00 1.04
------------ ----------- ---------- ---------- ---------- ------------- ------------
Legend:
- after 1st itr: ratio of before/after time for the first benchmarking iteration.
- before/after: ratio of before/after time. Higher is better for after. Above 1 represents a speedup.
```
Diffstat (limited to 'test/ruby')
| -rw-r--r-- | test/ruby/test_backtrace.rb | 6 | ||||
| -rw-r--r-- | test/ruby/test_settracefunc.rb | 12 |
2 files changed, 10 insertions, 8 deletions
diff --git a/test/ruby/test_backtrace.rb b/test/ruby/test_backtrace.rb index fca7b62030..1f96c0e4f3 100644 --- a/test/ruby/test_backtrace.rb +++ b/test/ruby/test_backtrace.rb @@ -223,15 +223,15 @@ class TestBacktrace < Test::Unit::TestCase @res = caller_locations(2, 1).inspect end @line = __LINE__ + 1 - [1].map.map { [1].map.map { foo } } - assert_equal("[\"#{__FILE__}:#{@line}:in 'Array#map'\"]", @res) + [1].map!.map { [1].map!.map { foo } } + assert_equal("[\"#{__FILE__}:#{@line}:in 'Array#map!'\"]", @res) end def test_caller_location_path_cfunc_iseq_no_pc def self.foo @res = caller_locations(2, 1)[0].path end - [1].map.map { [1].map.map { foo } } + [1].map!.map { [1].map!.map { foo } } assert_equal(__FILE__, @res) end diff --git a/test/ruby/test_settracefunc.rb b/test/ruby/test_settracefunc.rb index 62e8cf123b..c7998ef1f1 100644 --- a/test/ruby/test_settracefunc.rb +++ b/test/ruby/test_settracefunc.rb @@ -680,10 +680,8 @@ CODE # [:c_return, 1, "xyzzy", TracePoint, :trace, TracePoint, nil, nil], [:line, 4, 'xyzzy', self.class, method, self, :outer, :nothing], - [:c_call, 4, 'xyzzy', Integer, :times, 1, nil, nil], [:line, 4, 'xyzzy', self.class, method, self, nil, :nothing], [:line, 5, 'xyzzy', self.class, method, self, :inner, :nothing], - [:c_return, 4, "xyzzy", Integer, :times, 1, nil, nil], [:line, 7, 'xyzzy', self.class, method, self, :outer, :nothing], [:c_call, 7, "xyzzy", Class, :inherited, Object, nil, nil], [:c_return, 7, "xyzzy", Class, :inherited, Object, nil, nil], @@ -1069,10 +1067,12 @@ CODE # pp events # expected_events = [[:b_call, :test_tracepoint_block, TestSetTraceFunc, TestSetTraceFunc, nil], - [:c_call, :map, Array, Array, nil], + [:call, :map, Array, Array, nil], [:b_call, :test_tracepoint_block, TestSetTraceFunc, TestSetTraceFunc, nil], [:b_return, :test_tracepoint_block, TestSetTraceFunc, TestSetTraceFunc, 3], - [:c_return, :map, Array, Array, [3]], + [:c_call, :<<, Array, Array, nil], + [:c_return, :<<, Array, Array, [3]], + [:return, :map, Array, Array, [3]], [:call, :method_for_test_tracepoint_block, TestSetTraceFunc, TestSetTraceFunc, nil], [:b_call, :test_tracepoint_block, TestSetTraceFunc, TestSetTraceFunc, nil], [:b_return, :test_tracepoint_block, TestSetTraceFunc, TestSetTraceFunc, 4], @@ -1386,8 +1386,9 @@ CODE } assert_equal([ :b_call, - :c_call, + :call, :b_call, + :c_call, :call, :b_call, ], events) @@ -1409,6 +1410,7 @@ CODE assert_equal([ :b_return, :c_return, + :return, :b_return, :return, :b_return |
