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 {
38
38
@Flag ( help: " Exclude running NSRegex benchmarks " )
39
39
var excludeNs = false
40
40
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
+ """ )
42
48
var enableTracing : Bool = false
43
49
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
+ """ )
45
57
var enableMetrics : Bool = false
46
58
47
59
@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 {
400
400
mutating func cycle( ) {
401
401
_checkInvariants ( )
402
402
assert ( state == . inProgress)
403
+
404
+ #if PROCESSOR_MEASUREMENTS_ENABLED
403
405
if cycleCount == 0 {
404
406
trace ( )
405
407
measureMetrics ( )
@@ -410,6 +412,8 @@ extension Processor {
410
412
measureMetrics ( )
411
413
_checkInvariants ( )
412
414
}
415
+ #endif
416
+
413
417
let ( opcode, payload) = fetch ( ) . destructure
414
418
switch opcode {
415
419
case . invalid:
Original file line number Diff line number Diff line change @@ -30,7 +30,9 @@ struct Executor {
30
30
input: input,
31
31
subjectBounds: subjectBounds,
32
32
searchBounds: searchBounds)
33
+ #if PROCESSOR_MEASUREMENTS_ENABLED
33
34
defer { if cpu. shouldMeasureMetrics { cpu. printMetrics ( ) } }
35
+ #endif
34
36
var low = searchBounds. lowerBound
35
37
let high = searchBounds. upperBound
36
38
while true {
@@ -57,7 +59,9 @@ struct Executor {
57
59
) throws -> Regex < Output > . Match ? {
58
60
var cpu = engine. makeProcessor (
59
61
input: input, bounds: subjectBounds, matchMode: mode)
62
+ #if PROCESSOR_MEASUREMENTS_ENABLED
60
63
defer { if cpu. shouldMeasureMetrics { cpu. printMetrics ( ) } }
64
+ #endif
61
65
return try _match ( input, from: subjectBounds. lowerBound, using: & cpu)
62
66
}
63
67
You can’t perform that action at this time.
0 commit comments