@@ -2,7 +2,7 @@ import ArgumentParser
22
33@main
44struct Runner : ParsableCommand {
5- @Argument ( help: " Names of benchmarks to run" )
5+ @Argument ( help: " Patterns for benchmarks to run" )
66 var specificBenchmarks : [ String ] = [ ]
77
88 @Flag ( help: " Run only once for profiling purposes " )
@@ -20,19 +20,30 @@ struct Runner: ParsableCommand {
2020 @Flag ( help: " Should the results be saved " )
2121 var save = false
2222
23- @Flag ( help: " Compare this result with the latest saved result " )
23+ @Flag ( help: " Compare this result with a saved result " )
2424 var compare = false
2525
2626 @Option ( help: " The result file to compare against, if this flag is not set it will compare against the most recent result file " )
2727 var compareFile : String ?
2828
29+ @Flag ( help: " Exclude the comparisons to NSRegex " )
30+ var excludeNs = false
31+
2932 mutating func run( ) throws {
3033 var runner = BenchmarkRunner . makeRunner ( samples, outputPath)
3134
32- // todo: regex based filter
35+ if excludeNs {
36+ self . specificBenchmarks. append ( " ((?!NS).)* " )
37+ }
38+
3339 if !self . specificBenchmarks. isEmpty {
34- runner. suite = runner. suite. filter { b in specificBenchmarks. contains ( b. name) }
40+ runner. suite = runner. suite. filter { b in
41+ specificBenchmarks. contains { pattern in
42+ try ! Regex ( pattern) . wholeMatch ( in: b. name) != nil
43+ }
44+ }
3545 }
46+
3647 switch ( profile, debug) {
3748 case ( true , true ) : print ( " Cannot run both profile and debug " )
3849 case ( true , false ) : runner. profile ( )
0 commit comments