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
3 changes: 2 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ jobs:
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true

- name: Run tests
run: rake test
run: bundle exec rake test

benchmark-default:
runs-on: ubuntu-latest
Expand Down
10 changes: 10 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# frozen_string_literal: true

source "https://rubygems.org"

gem "csv"
gem "gruff"
gem "minitest", "~> 5.0"
gem "minitest-mock"
gem "rake"
gem "rmagick"
46 changes: 46 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
GEM
remote: https://rubygems.org/
specs:
bigdecimal (4.0.1)
csv (3.3.5)
gruff (0.29.0)
bigdecimal (>= 3.0)
histogram
rmagick (>= 5.5)
histogram (0.2.4.1)
minitest (5.27.0)
minitest-mock (5.27.0)
observer (0.1.2)
pkg-config (1.6.5)
rake (13.3.1)
rmagick (6.1.5)
observer (~> 0.1)
pkg-config (~> 1.4)

PLATFORMS
arm64-darwin-24
ruby
x86_64-linux

DEPENDENCIES
csv
gruff
minitest (~> 5.0)
minitest-mock
rake
rmagick

CHECKSUMS
bigdecimal (4.0.1) sha256=8b07d3d065a9f921c80ceaea7c9d4ae596697295b584c296fe599dd0ad01c4a7
csv (3.3.5) sha256=6e5134ac3383ef728b7f02725d9872934f523cb40b961479f69cf3afa6c8e73f
gruff (0.29.0) sha256=ab808cbf507abda7ffacd4ba5805a43c47ad0ec6aa2a7b125cf8a165110047a0
histogram (0.2.4.1) sha256=9a6e379172b88ea842ab71700a535dd037185a4e17abcce742c7444679ae2abc
minitest (5.27.0) sha256=2d3b17f8a36fe7801c1adcffdbc38233b938eb0b4966e97a6739055a45fa77d5
minitest-mock (5.27.0) sha256=7040ed7185417a966920987eaa6eaf1be4ea1fc5b25bb03ff4703f98564a55b0
observer (0.1.2) sha256=d8a3107131ba661138d748e7be3dbafc0d82e732fffba9fccb3d7829880950ac
pkg-config (1.6.5) sha256=33f9f81c5322983d22b439b8b672f27777b406fea23bfec74ff14bbeb42ec733
rake (13.3.1) sha256=8c9e89d09f66a26a01264e7e3480ec0607f0c497a861ef16063604b1b08eb19c
rmagick (6.1.5) sha256=91c1734cc0effc3b1be18e6705ea0353d73cb492547002f542763fa08445acd1

BUNDLED WITH
4.0.3
16 changes: 10 additions & 6 deletions benchmarks/ruby-lsp/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,18 @@ GEM
specs:
language_server-protocol (3.17.0.5)
logger (1.7.0)
prism (1.4.0)
rbs (3.9.4)
prism (1.7.0)
rbs (4.0.0.dev.5)
logger
prism (>= 1.3.0)
tsort
ruby-lsp (0.17.17)
language_server-protocol (~> 3.17.0)
prism (~> 1.0)
rbs (>= 3, < 4)
sorbet-runtime (>= 0.5.10782)
sorbet-runtime (0.5.12366)
sorbet-runtime (0.6.12878)
tsort (0.2.0)

PLATFORMS
ruby
Expand All @@ -23,10 +26,11 @@ DEPENDENCIES
CHECKSUMS
language_server-protocol (3.17.0.5) sha256=fd1e39a51a28bf3eec959379985a72e296e9f9acfce46f6a79d31ca8760803cc
logger (1.7.0) sha256=196edec7cc44b66cfb40f9755ce11b392f21f7967696af15d274dde7edff0203
prism (1.4.0) sha256=dc0e3e00e93160213dc2a65519d9002a4a1e7b962db57d444cf1a71565bb703e
rbs (3.9.4) sha256=8e42c8f133fc2d94b65f62f34479546de1247b79892b57584f625b61e518a5d7
prism (1.7.0) sha256=10062f734bf7985c8424c44fac382ac04a58124ea3d220ec3ba9fe4f2da65103
rbs (4.0.0.dev.5) sha256=273938e5a9c7f06b041be583588f2aa1976149bda2ce213e33e129c51534e174
ruby-lsp (0.17.17) sha256=6147b40dd3fe344369c1ba42da9b4ac21334ccadf0d321a0cba782624a9b798b
sorbet-runtime (0.5.12366) sha256=67e432b5b3581ed0c991de2178dddcf9e397b6d9b31995849795b0a802837afe
sorbet-runtime (0.6.12878) sha256=e1efa4b73f6d111025d9978a63b6c0f31ab7603027ce272591449d10888c83c9
tsort (0.2.0) sha256=9650a793f6859a43b6641671278f79cfead60ac714148aabe4e3f0060480089f

BUNDLED WITH
4.0.0
25 changes: 22 additions & 3 deletions lib/benchmark_suite.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,25 @@ def run(ruby:, ruby_description:)
env = benchmark_env(ruby)
caller_json_path = ENV["RESULT_JSON_PATH"]

# Capture quiet setting before entering unbundled env (which clears ENV)
quiet = ENV['BENCHMARK_QUIET'] == '1'

benchmark_entries.each_with_index do |entry, idx|
puts("Running benchmark \"#{entry.name}\" (#{idx+1}/#{benchmark_entries.length})")

result_json_path = caller_json_path || File.join(out_path, "temp#{Process.pid}.json")
cmd_prefix = base_cmd(ruby_description, entry.name)
result = run_single_benchmark(entry.script_path, result_json_path, ruby, cmd_prefix, env, entry.name)

# Clear project-level Bundler environment so benchmarks run in a clean context.
# Benchmarks that need Bundler (e.g., railsbench) set up their own via use_gemfile.
# This is important when running tests under `bundle exec rake test`.
result = if defined?(Bundler)
Bundler.with_unbundled_env do
Copy link
Member Author

@st0012 st0012 Jan 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added here because if someone runs benchmark with bundle, like bundle exec ruby -I harness benchmarks/fib.rb, it should pass & not be affected by project-level bundle too.

run_single_benchmark(entry.script_path, result_json_path, ruby, cmd_prefix, env, entry.name, quiet: quiet)
end
else
run_single_benchmark(entry.script_path, result_json_path, ruby, cmd_prefix, env, entry.name, quiet: quiet)
end

if result[:success]
bench_data[entry.name] = process_benchmark_result(result_json_path, result[:command], delete_file: !caller_json_path)
Expand Down Expand Up @@ -120,7 +133,7 @@ def filter_entries(entries, categories:, name_filters:, excludes:, directory_map
entries.select { |entry| filter.match?(entry.name) }
end

def run_single_benchmark(script_path, result_json_path, ruby, cmd_prefix, env, benchmark_name)
def run_single_benchmark(script_path, result_json_path, ruby, cmd_prefix, env, benchmark_name, quiet: false)
# Fix for jruby/jruby#7394 in JRuby 9.4.2.0
script_path = File.expand_path(script_path)

Expand All @@ -141,7 +154,7 @@ def run_single_benchmark(script_path, result_json_path, ruby, cmd_prefix, env, b
].compact

# Do the benchmarking
result = BenchmarkRunner.check_call(cmd.shelljoin, env: env, raise_error: false)
result = BenchmarkRunner.check_call(cmd.shelljoin, env: env, raise_error: false, quiet: quiet)
result[:command] = cmd.shelljoin
result
ensure
Expand Down Expand Up @@ -177,6 +190,12 @@ def benchmark_env(ruby)
end
end

# Pass benchmark configuration env vars to subprocess.
# These may be set after bundler loads, so they'd be lost with with_unbundled_env.
["WARMUP_ITRS", "MIN_BENCH_ITRS", "MIN_BENCH_TIME", "YJIT_BENCH_STATS", "ZJIT_BENCH_STATS"].each do |var|
env[var] = ENV[var] if ENV.key?(var)
end

env
end

Expand Down
1 change: 1 addition & 0 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
require 'minitest/autorun'
require 'minitest/mock'
Loading