File tree 5 files changed +50
-3
lines changed
5 files changed +50
-3
lines changed Original file line number Diff line number Diff line change 1
1
## Unreleased
2
+ - ** fix** Support sub-nanosecond precision on Cargo benchmarks (#246 )
3
+
2
4
3
5
<a name =" v1.20.1 " ></a >
4
6
# [ v1.20.1] ( https://github.com/benchmark-action/github-action-benchmark/releases/tag/v1.20.1 ) - 02 Apr 2024
Original file line number Diff line number Diff line change @@ -314,8 +314,8 @@ function extractCargoResult(output: string): BenchmarkResult[] {
314
314
const lines = output . split ( / \r ? \n / g) ;
315
315
const ret = [ ] ;
316
316
// Example:
317
- // test bench_fib_20 ... bench: 37,174 ns/iter (+/- 7,527)
318
- const reExtract = / ^ t e s t ( .+ ) \s + \. \. \. b e n c h : \s + ( [ 0 - 9 , ] + ) n s \/ i t e r \( \+ \/ - ( [ 0 - 9 , ] + ) \) $ / ;
317
+ // test bench_fib_20 ... bench: 37,174.25 ns/iter (+/- 7,527.43 )
318
+ const reExtract = / ^ t e s t ( .+ ) \s + \. \. \. b e n c h : \s + ( [ 0 - 9 , . ] + ) n s \/ i t e r \( \+ \/ - ( [ 0 - 9 , . ] + ) \) $ / ;
319
319
const reComma = / , / g;
320
320
321
321
for ( const line of lines ) {
@@ -325,7 +325,7 @@ function extractCargoResult(output: string): BenchmarkResult[] {
325
325
}
326
326
327
327
const name = m [ 1 ] . trim ( ) ;
328
- const value = parseInt ( m [ 2 ] . replace ( reComma , '' ) , 10 ) ;
328
+ const value = parseFloat ( m [ 2 ] . replace ( reComma , '' ) ) ;
329
329
const range = m [ 3 ] . replace ( reComma , '' ) ;
330
330
331
331
ret . push ( {
Original file line number Diff line number Diff line change @@ -175,6 +175,35 @@ exports[`extractResult() extracts benchmark output from cargo - cargo_output2.tx
175
175
}
176
176
` ;
177
177
178
+ exports [` extractResult() extracts benchmark output from cargo - cargo_output3.txt 1` ] = `
179
+ {
180
+ " benches" : [
181
+ {
182
+ " name" : " bench_fib_10" ,
183
+ " range" : " ± 2.21" ,
184
+ " unit" : " ns/iter" ,
185
+ " value" : 148.7 ,
186
+ },
187
+ {
188
+ " name" : " bench_fib_20" ,
189
+ " range" : " ± 440.25" ,
190
+ " unit" : " ns/iter" ,
191
+ " value" : 18794.12 ,
192
+ },
193
+ ],
194
+ " commit" : {
195
+ " author" : null ,
196
+ " committer" : null ,
197
+ " id" : " 123456789abcdef" ,
198
+ " message" : " this is dummy" ,
199
+ " timestamp" : " dummy timestamp" ,
200
+ " url" : " https://github.com/dummy/repo" ,
201
+ },
202
+ " date" : 1712131503296 ,
203
+ " tool" : " cargo" ,
204
+ }
205
+ ` ;
206
+
178
207
exports [` extractResult() extracts benchmark output from cargo - criterion_output.txt 1` ] = `
179
208
{
180
209
" benches" : [
Original file line number Diff line number Diff line change
1
+
2
+ running 0 tests
3
+
4
+ test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
5
+
6
+
7
+ running 2 tests
8
+ test bench_fib_10 ... bench: 148.70 ns/iter (+/- 2.21)
9
+ test bench_fib_20 ... bench: 18,794.12 ns/iter (+/- 440.25)
10
+
11
+ test result: ok. 0 passed; 0 failed; 0 ignored; 2 measured; 0 filtered out
12
+
Original file line number Diff line number Diff line change @@ -67,6 +67,10 @@ describe('extractResult()', function () {
67
67
tool : 'cargo' ,
68
68
file : 'cargo_output2.txt' ,
69
69
} ,
70
+ {
71
+ tool : 'cargo' ,
72
+ file : 'cargo_output3.txt' ,
73
+ } ,
70
74
{
71
75
tool : 'cargo' ,
72
76
file : 'criterion_output.txt' ,
You can’t perform that action at this time.
0 commit comments