File tree Expand file tree Collapse file tree 5 files changed +50
-3
lines changed Expand file tree Collapse file tree 5 files changed +50
-3
lines changed Original file line number Diff line number Diff line change 11## Unreleased
2+ - ** fix** Support sub-nanosecond precision on Cargo benchmarks (#246 )
3+
24
35<a name =" v1.20.1 " ></a >
46# [ 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[] {
314314 const lines = output . split ( / \r ? \n / g) ;
315315 const ret = [ ] ;
316316 // 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 , . ] + ) \) $ / ;
319319 const reComma = / , / g;
320320
321321 for ( const line of lines ) {
@@ -325,7 +325,7 @@ function extractCargoResult(output: string): BenchmarkResult[] {
325325 }
326326
327327 const name = m [ 1 ] . trim ( ) ;
328- const value = parseInt ( m [ 2 ] . replace ( reComma , '' ) , 10 ) ;
328+ const value = parseFloat ( m [ 2 ] . replace ( reComma , '' ) ) ;
329329 const range = m [ 3 ] . replace ( reComma , '' ) ;
330330
331331 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
175175}
176176` ;
177177
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+
178207exports [` extractResult() extracts benchmark output from cargo - criterion_output.txt 1` ] = `
179208{
180209 " 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 () {
6767 tool : 'cargo' ,
6868 file : 'cargo_output2.txt' ,
6969 } ,
70+ {
71+ tool : 'cargo' ,
72+ file : 'cargo_output3.txt' ,
73+ } ,
7074 {
7175 tool : 'cargo' ,
7276 file : 'criterion_output.txt' ,
You can’t perform that action at this time.
0 commit comments