diff --git a/benchmarks.yml b/benchmarks.yml index bc6060b2..2f3b3578 100644 --- a/benchmarks.yml +++ b/benchmarks.yml @@ -256,6 +256,10 @@ throw: category: micro single_file: true ractor: true +send_rubyfunc_inline: + desc: send_rubyfunc_inline repeatedly calls a small inlinable Ruby method with multiple arguments. + category: micro + single_file: true # # Ractor scaling benchmarks diff --git a/benchmarks/send_rubyfunc_inline.rb b/benchmarks/send_rubyfunc_inline.rb new file mode 100644 index 00000000..50f0efd8 --- /dev/null +++ b/benchmarks/send_rubyfunc_inline.rb @@ -0,0 +1,32 @@ +require_relative '../harness/loader' + +INNER_ITERATIONS = 10_000_000 +EXPECTED_RESULT = 2 * INNER_ITERATIONS * INNER_ITERATIONS + 4 * INNER_ITERATIONS + +def send_rubyfunc_inline_callee(a, b, c, d) + a + b + c + d +end + +def send_rubyfunc_inline_driver(limit) + total = 0 + i = 0 + + while i < limit + total += send_rubyfunc_inline_callee(i, i + 1, i + 2, i + 3) + i += 1 + end + + total +end + +@send_rubyfunc_inline_result = 0 + +100.times do + @send_rubyfunc_inline_result = send_rubyfunc_inline_driver(100) +end + +run_benchmark(20) do + @send_rubyfunc_inline_result = send_rubyfunc_inline_driver(INNER_ITERATIONS) +end + +raise "unexpected result: #{@send_rubyfunc_inline_result}" unless @send_rubyfunc_inline_result == EXPECTED_RESULT