@@ -174,15 +174,17 @@ def free_file_no(prefix)
174174 end
175175end
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
180182end
181183
182184# Check if the name matches any of the names in a list of filters
183185def 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 ) )
187189end
188190
@@ -227,8 +229,16 @@ def run_benchmarks(ruby:, ruby_description:, categories:, name_filters:, out_pat
227229 bench_data = { }
228230 bench_failures = { }
229231
232+ bench_dir = "benchmarks"
233+
234+ if categories == [ 'ractor-only' ]
235+ bench_dir = File . join ( bench_dir , "ractor" )
236+ harness = "harness-ractor"
237+ categories = [ ]
238+ end
239+
230240 # Get the list of benchmark files/directories matching name filters
231- bench_files = Dir . children ( 'benchmarks' ) . sort . filter do |entry |
241+ bench_files = Dir . children ( bench_dir ) . sort . filter do |entry |
232242 match_filter ( entry , categories : categories , name_filters : name_filters )
233243 end
234244
@@ -242,7 +252,7 @@ def run_benchmarks(ruby:, ruby_description:, categories:, name_filters:, out_pat
242252 puts ( "Running benchmark \" #{ bench_name } \" (#{ idx +1 } /#{ bench_files . length } )" )
243253
244254 # Path to the benchmark runner script
245- script_path = File . join ( 'benchmarks' , entry )
255+ script_path = File . join ( bench_dir , entry )
246256
247257 if !script_path . end_with? ( '.rb' )
248258 script_path = File . join ( script_path , 'benchmark.rb' )
@@ -360,14 +370,21 @@ def run_benchmarks(ruby:, ruby_description:, categories:, name_filters:, out_pat
360370 args . out_override = v
361371 end
362372
363- opts . on ( "--category=headline,other,micro" , "when given, only benchmarks with specified categories will run" ) do |v |
373+ opts . on ( "--category=headline,other,micro,ractor " , "when given, only benchmarks with specified categories will run" ) do |v |
364374 args . categories += v . split ( "," )
375+ if args . categories == [ 'ractor' ]
376+ args . harness = 'harness-ractor'
377+ end
365378 end
366379
367380 opts . on ( "--headline" , "when given, headline benchmarks will be run" ) do |v |
368381 args . categories += [ "headline" ]
369382 end
370383
384+ opts . on ( "--ractor-only" , "ractor-only benchmarks (benchmarks/ractor/*.rb) will be run" ) do |v |
385+ args . categories = [ "ractor-only" ]
386+ end
387+
371388 opts . on ( "--name_filters=x,y,z" , Array , "when given, only benchmarks with names that contain one of these strings will run" ) do |list |
372389 args . name_filters = list
373390 end
0 commit comments