Skip to content

Commit 824e057

Browse files
authored
Merge pull request #545 from ruby/claude/elastic-elbakyan-08a9f6
Fix benchmarks that fail on Windows
2 parents b5e2147 + 1eb06e4 commit 824e057

8 files changed

Lines changed: 33 additions & 4 deletions

File tree

‎benchmarks/activerecord/Gemfile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
source "https://rubygems.org"
22
gem "activerecord", "~> 8.0"
3-
gem "sqlite3", platform: :ruby
3+
gem "sqlite3", platforms: [:ruby, :windows]
44
gem "activerecord-jdbc-adapter", github: "k0kubun/activerecord-jdbc-adapter", ref: "rails-8.1-sqlite3", platform: :jruby
55
gem "activerecord-jdbcsqlite3-adapter", github: "k0kubun/activerecord-jdbc-adapter", ref: "rails-8.1-sqlite3", platform: :jruby
66
gem "mutex_m"

‎benchmarks/gvl_release_acquire/benchmark.rb‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
11
require_relative "../../harness/loader"
22

3+
# Windows has no /dev/zero, so read the same zeros from a regular file kept in data/.
4+
ZERO_PATH = if File.exist?("/dev/zero")
5+
"/dev/zero"
6+
else
7+
File.join(__dir__, "data", "zero").tap do |path|
8+
unless File.size?(path) == 1_000_000
9+
Dir.mkdir(File.dirname(path)) unless Dir.exist?(File.dirname(path))
10+
File.binwrite(path, "\0" * 1_000_000)
11+
end
12+
end
13+
end.freeze
14+
315
run_benchmark(5) do |num_rs, ractor_args|
416
output = File.open(File::NULL, "wb")
5-
input = File.open("/dev/zero", "rb")
17+
input = File.open(ZERO_PATH, "rb")
618
100_000.times do
719
output.write(input.read(10))
820
end

‎benchmarks/lobsters/Gemfile‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ gem "cgi" # Workaround cgi extraction in Ruby 3.5.0-dev
1111
gem rails_gem, "~> 8.0"
1212
end
1313

14+
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
15+
gem "tzinfo-data", platforms: [:windows, :jruby]
16+
1417
gem "sqlite3"
1518
#gem "mysql2"
1619

‎benchmarks/lobsters/Gemfile.lock‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,7 @@ DEPENDENCIES
372372
sqlite3
373373
stackprof
374374
svg-graph
375+
tzinfo-data
375376
vcr
376377
webmock
377378

‎benchmarks/railsbench/Gemfile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ gem 'sprockets-rails', '3.2.2'
2020

2121
gem 'stackprof', platforms: :mri
2222
# Use sqlite3 as the database for Active Record
23-
gem 'sqlite3', platform: :ruby
23+
gem 'sqlite3', platforms: [:ruby, :windows]
2424
gem 'activerecord-jdbc-adapter', github: 'k0kubun/activerecord-jdbc-adapter', ref: 'rails-8.1-sqlite3', platform: :jruby
2525
gem 'activerecord-jdbcsqlite3-adapter', github: 'k0kubun/activerecord-jdbc-adapter', ref: 'rails-8.1-sqlite3', platform: :jruby
2626
# Use webrick for the web server since it's easy to install.

‎benchmarks/rubyboy/benchmark.rb‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,16 @@
1313
# The rom is included in the gem in a sibling directory to the rubyboy code.
1414
ROM_PATH = File.expand_path("../../roms/tobu.gb", $".detect { |x| x.end_with?("/rubyboy/emulator_headless.rb") }).freeze
1515

16+
# Rubyboy opens the ROM with mode "r", which converts CRLF to LF on Windows.
17+
if Gem.win_platform?
18+
File.singleton_class.prepend(Module.new do
19+
def open(path, *args, **kwargs, &block)
20+
args[0] = "rb" if path == ROM_PATH && args[0] == "r"
21+
super(path, *args, **kwargs, &block)
22+
end
23+
end)
24+
end
25+
1626
# A count of 500 produces results similar to our optcarrot benchmark.
1727
# It's possible there is a number that produces a consistent benchmark without
1828
# needing to re-initialize but not sure how to determine that.

‎benchmarks/sequel/Gemfile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
source "https://rubygems.org"
22
gem "sequel", "~> 5.63"
3-
gem "sqlite3", "~> 1.4", platform: :ruby
3+
gem "sqlite3", "~> 1.4", platforms: [:ruby, :windows]
44
gem "jdbc-sqlite3", "~> 3.32.3", platform: :jruby
55

66
gem "bigdecimal"

‎benchmarks/shipit/benchmark.rb‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
require 'securerandom'
1212
ENV['SECRET_KEY_BASE'] = SecureRandom.hex(128)
1313

14+
# shipit-engine requires pty, which Windows lacks, only to run deploy commands that the benchmark never starts.
15+
$LOADED_FEATURES << File.join(RbConfig::CONFIG["archdir"], "pty.so") if Gem.win_platform?
16+
1417
require_relative 'config/environment'
1518
require_relative "route_generator"
1619

0 commit comments

Comments
 (0)