@@ -183,9 +183,28 @@ def benchmark_categories(name)
183183
184184# Check if the name matches any of the names in a list of filters
185185def match_filter ( entry , categories :, name_filters :)
186+ name_filters = process_name_filters ( name_filters )
186187 name = entry . sub ( /\. rb\z / , '' )
187188 ( categories . empty? || benchmark_categories ( name ) . any? { |cat | categories . include? ( cat ) } ) &&
188- ( name_filters . empty? || name_filters . include? ( name ) )
189+ ( name_filters . empty? || name_filters . any? { |filter | filter === name } )
190+ end
191+
192+ # process "/my_benchmark/i" into /my_benchmark/i
193+ def process_name_filters ( name_filters )
194+ name_filters . map do |name_filter |
195+ if name_filter [ 0 ] == "/"
196+ regexp_str = name_filter [ 1 ..-1 ] . reverse . sub ( /\A (\w *)\/ / , "" )
197+ regexp_opts = $1. to_s
198+ regexp_str . reverse!
199+ r = /#{ regexp_str } /
200+ if !regexp_opts . empty?
201+ r = Regexp . compile ( r . to_s , regexp_opts )
202+ end
203+ r
204+ else
205+ name_filter
206+ end
207+ end
189208end
190209
191210# Resolve the pre_init file path into a form that can be required
@@ -332,6 +351,7 @@ def run_benchmarks(ruby:, ruby_description:, categories:, name_filters:, out_pat
332351 graph : false ,
333352 no_pinning : false ,
334353 turbo : false ,
354+ skip_yjit : false ,
335355} )
336356
337357OptionParser . new do |opts |
@@ -372,23 +392,27 @@ def run_benchmarks(ruby:, ruby_description:, categories:, name_filters:, out_pat
372392
373393 opts . on ( "--category=headline,other,micro,ractor" , "when given, only benchmarks with specified categories will run" ) do |v |
374394 args . categories += v . split ( "," )
375- if args . categories == [ ' ractor' ]
376- args . harness = ' harness-ractor'
395+ if args . categories == [ " ractor" ]
396+ args . harness = " harness-ractor"
377397 end
378398 end
379399
380- opts . on ( "--headline" , "when given, headline benchmarks will be run" ) do | v |
400+ opts . on ( "--headline" , "when given, headline benchmarks will be run" ) do
381401 args . categories += [ "headline" ]
382402 end
383403
384- opts . on ( "--ractor-only" , "ractor-only benchmarks (benchmarks/ractor/*.rb) will be run" ) do | v |
404+ opts . on ( "--ractor-only" , "ractor-only benchmarks (benchmarks/ractor/*.rb) will be run" ) do
385405 args . categories = [ "ractor-only" ]
386406 end
387407
388408 opts . on ( "--name_filters=x,y,z" , Array , "when given, only benchmarks with names that contain one of these strings will run" ) do |list |
389409 args . name_filters = list
390410 end
391411
412+ opts . on ( "--skip-yjit" , "Don't run with yjit after interpreter" ) do
413+ args . skip_yjit = true
414+ end
415+
392416 opts . on ( "--harness=HARNESS_DIR" , "which harness to use" ) do |v |
393417 v = "harness-#{ v } " unless v . start_with? ( 'harness' )
394418 args . harness = v
@@ -446,7 +470,7 @@ def run_benchmarks(ruby:, ruby_description:, categories:, name_filters:, out_pat
446470
447471# If -e is not specified, benchmark the current Ruby. Compare it with YJIT if available.
448472if args . executables . empty?
449- if have_yjit? ( RbConfig . ruby )
473+ if have_yjit? ( RbConfig . ruby ) && ! args . skip_yjit
450474 args . executables [ "interp" ] = [ RbConfig . ruby ]
451475 args . executables [ "yjit" ] = [ RbConfig . ruby , "--yjit" , *args . yjit_opts . shellsplit ]
452476 else
0 commit comments