|
39 | 39 | mvn clean compile test-compile |
40 | 40 | # Run JMH with reduced iterations for faster PR feedback |
41 | 41 | # Uses: 2 warmup iterations, 3 measurement iterations instead of default 5,5 |
| 42 | + # Pattern targets only EnforcerBenchmarkTest, not CachedEnforcerBenchmarkTest |
42 | 43 | java -cp "target/test-classes:target/classes:$(mvn dependency:build-classpath -DincludeScope=test -Dmdep.outputFile=/dev/stdout -q)" \ |
43 | | - org.openjdk.jmh.Main ".*EnforcerBenchmarkTest.*" -wi 2 -i 3 -f 1 -r 1 -w 1 -rf json -rff pr-results.json 2>&1 | tee pr-bench.txt |
| 44 | + org.openjdk.jmh.Main "^.*\\.EnforcerBenchmarkTest\\." -wi 2 -i 3 -f 1 -r 1 -w 1 -rf json -rff pr-results.json 2>&1 | tee pr-bench.txt |
44 | 45 |
|
45 | 46 | # Checkout base branch and run benchmark |
46 | 47 | - name: Checkout base branch |
|
57 | 58 | mvn clean compile test-compile |
58 | 59 | # Run JMH with reduced iterations for faster PR feedback |
59 | 60 | # Uses: 2 warmup iterations, 3 measurement iterations instead of default 5,5 |
| 61 | + # Pattern targets only EnforcerBenchmarkTest, not CachedEnforcerBenchmarkTest |
60 | 62 | java -cp "target/test-classes:target/classes:$(mvn dependency:build-classpath -DincludeScope=test -Dmdep.outputFile=/dev/stdout -q)" \ |
61 | | - org.openjdk.jmh.Main ".*EnforcerBenchmarkTest.*" -wi 2 -i 3 -f 1 -r 1 -w 1 -rf json -rff ../base-results.json 2>&1 | tee ../base-bench.txt |
| 63 | + org.openjdk.jmh.Main "^.*\\.EnforcerBenchmarkTest\\." -wi 2 -i 3 -f 1 -r 1 -w 1 -rf json -rff ../base-results.json 2>&1 | tee ../base-bench.txt |
62 | 64 |
|
63 | 65 | # Compare benchmarks |
64 | 66 | - name: Parse and compare benchmarks |
@@ -100,13 +102,22 @@ jobs: |
100 | 102 | def parse_jmh_output(filename): |
101 | 103 | """Parse JMH benchmark output and extract throughput results.""" |
102 | 104 | results = {} |
103 | | - with open(filename, 'r') as f: |
104 | | - content = f.read() |
| 105 | + |
| 106 | + if not os.path.exists(filename): |
| 107 | + return {} |
| 108 | + |
| 109 | + try: |
| 110 | + with open(filename, 'r') as f: |
| 111 | + content = f.read() |
| 112 | + except (IOError, OSError) as e: |
| 113 | + print(f"Error reading file {filename}: {e}", file=sys.stderr) |
| 114 | + return {} |
105 | 115 | |
106 | 116 | # Match benchmark results with throughput mode |
107 | 117 | # Format: Benchmark Mode Cnt Score Error Units |
108 | 118 | # org.casbin...benchmarkXXX thrpt 5 12345.678 ± 123.456 ops/ms |
109 | | - pattern = r'(\S+)\s+thrpt\s+\d+\s+([\d.]+)\s+[±]\s+([\d.]+)\s+ops/ms' |
| 119 | + # Using flexible pattern for plus-minus symbol to handle different encodings |
| 120 | + pattern = r'(\S+)\s+thrpt\s+\d+\s+([\d.]+)\s+[±+\-]\s+([\d.]+)\s+ops/ms' |
110 | 121 | |
111 | 122 | for match in re.finditer(pattern, content): |
112 | 123 | benchmark_name = match.group(1) |
|
0 commit comments