File tree Expand file tree Collapse file tree 3 files changed +22
-2
lines changed Expand file tree Collapse file tree 3 files changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -38,10 +38,22 @@ struct Runner: ParsableCommand {
3838 @Flag ( help: " Exclude running NSRegex benchmarks " )
3939 var excludeNs = false
4040
41- @Flag ( help: " Enable tracing of the engine (warning: lots of output) " )
41+ @Flag ( help: """
42+ Enable tracing of the engine (warning: lots of output). Prints out processor state each cycle
43+
44+ Note: swift-experimental-string-processing must be built with processor measurements enabled
45+
46+ swift build -c release -Xswiftc -DPROCESSOR_MEASUREMENTS_ENABLED
47+ """ )
4248 var enableTracing : Bool = false
4349
44- @Flag ( help: " Enable engine metrics (warning: lots of output) " )
50+ @Flag ( help: """
51+ Enable engine metrics (warning: lots of output). Prints out cycle count, instruction counts, number of backtracks
52+
53+ Note: swift-experimental-string-processing must be built with processor measurements enabled
54+
55+ swift build -c release -Xswiftc -DPROCESSOR_MEASUREMENTS_ENABLED
56+ """ )
4557 var enableMetrics : Bool = false
4658
4759 @Flag ( help: " Include firstMatch benchmarks in CrossBenchmark (off by default " )
Original file line number Diff line number Diff line change @@ -400,6 +400,8 @@ extension Processor {
400400 mutating func cycle( ) {
401401 _checkInvariants ( )
402402 assert ( state == . inProgress)
403+
404+ #if PROCESSOR_MEASUREMENTS_ENABLED
403405 if cycleCount == 0 {
404406 trace ( )
405407 measureMetrics ( )
@@ -410,6 +412,8 @@ extension Processor {
410412 measureMetrics ( )
411413 _checkInvariants ( )
412414 }
415+ #endif
416+
413417 let ( opcode, payload) = fetch ( ) . destructure
414418 switch opcode {
415419 case . invalid:
Original file line number Diff line number Diff line change @@ -30,7 +30,9 @@ struct Executor {
3030 input: input,
3131 subjectBounds: subjectBounds,
3232 searchBounds: searchBounds)
33+ #if PROCESSOR_MEASUREMENTS_ENABLED
3334 defer { if cpu. shouldMeasureMetrics { cpu. printMetrics ( ) } }
35+ #endif
3436 var low = searchBounds. lowerBound
3537 let high = searchBounds. upperBound
3638 while true {
@@ -57,7 +59,9 @@ struct Executor {
5759 ) throws -> Regex < Output > . Match ? {
5860 var cpu = engine. makeProcessor (
5961 input: input, bounds: subjectBounds, matchMode: mode)
62+ #if PROCESSOR_MEASUREMENTS_ENABLED
6063 defer { if cpu. shouldMeasureMetrics { cpu. printMetrics ( ) } }
64+ #endif
6165 return try _match ( input, from: subjectBounds. lowerBound, using: & cpu)
6266 }
6367
You can’t perform that action at this time.
0 commit comments