Skip to content

Commit f40c24d

Browse files
committed
Modify run_benchmarks.rb to add 'ractor-only' category
1 parent 682056c commit f40c24d

File tree

1 file changed

+23
-6
lines changed

1 file changed

+23
-6
lines changed

run_benchmarks.rb

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -174,15 +174,17 @@ def free_file_no(prefix)
174174
end
175175
end
176176

177-
def benchmark_category(name)
177+
def benchmark_categories(name)
178178
metadata = benchmarks_metadata.find { |benchmark, _metadata| benchmark == name }&.last || {}
179-
metadata.fetch('category', 'other')
179+
categories = [metadata.fetch('category', 'other')]
180+
categories << 'ractor' if metadata['ractor']
181+
categories
180182
end
181183

182184
# Check if the name matches any of the names in a list of filters
183185
def match_filter(entry, categories:, name_filters:)
184186
name = entry.sub(/\.rb\z/, '')
185-
(categories.empty? || categories.include?(benchmark_category(name))) &&
187+
(categories.empty? || benchmark_categories(name).any? { |cat| categories.include?(cat) }) &&
186188
(name_filters.empty? || name_filters.include?(name))
187189
end
188190

@@ -237,8 +239,16 @@ def run_benchmarks(ruby:, ruby_description:, categories:, name_filters:, out_pat
237239
bench_data = {}
238240
bench_failures = {}
239241

242+
bench_dir = "benchmarks"
243+
244+
if categories == ['ractor-only']
245+
bench_dir = File.join(bench_dir, "ractor")
246+
harness = "harness-ractor"
247+
categories = []
248+
end
249+
240250
# Get the list of benchmark files/directories matching name filters
241-
bench_files = Dir.children('benchmarks').sort.filter do |entry|
251+
bench_files = Dir.children(bench_dir).sort.filter do |entry|
242252
match_filter(entry, categories: categories, name_filters: name_filters)
243253
end
244254

@@ -252,7 +262,7 @@ def run_benchmarks(ruby:, ruby_description:, categories:, name_filters:, out_pat
252262
puts("Running benchmark \"#{bench_name}\" (#{idx+1}/#{bench_files.length})")
253263

254264
# Path to the benchmark runner script
255-
script_path = File.join('benchmarks', entry)
265+
script_path = File.join(bench_dir, entry)
256266

257267
if !script_path.end_with?('.rb')
258268
script_path = File.join(script_path, 'benchmark.rb')
@@ -369,14 +379,21 @@ def run_benchmarks(ruby:, ruby_description:, categories:, name_filters:, out_pat
369379
args.out_override = v
370380
end
371381

372-
opts.on("--category=headline,other,micro", "when given, only benchmarks with specified categories will run") do |v|
382+
opts.on("--category=headline,other,micro,ractor", "when given, only benchmarks with specified categories will run") do |v|
373383
args.categories += v.split(",")
384+
if args.categories == ['ractor']
385+
args.harness = 'harness-ractor'
386+
end
374387
end
375388

376389
opts.on("--headline", "when given, headline benchmarks will be run") do |v|
377390
args.categories += ["headline"]
378391
end
379392

393+
opts.on("--ractor-only", "ractor-only benchmarks (benchmarks/ractor/*.rb) will be run") do |v|
394+
args.categories = ["ractor-only"]
395+
end
396+
380397
opts.on("--name_filters=x,y,z", Array, "when given, only benchmarks with names that contain one of these strings will run") do |list|
381398
args.name_filters = list
382399
end

0 commit comments

Comments
 (0)