File tree Expand file tree Collapse file tree 4 files changed +64
-5
lines changed Expand file tree Collapse file tree 4 files changed +64
-5
lines changed Original file line number Diff line number Diff line change @@ -313,9 +313,7 @@ async function getCommit(githubToken?: string, ref?: string): Promise<Commit> {
313313function extractCargoResult ( output : string ) : BenchmarkResult [ ] {
314314 const lines = output . split ( / \r ? \n / g) ;
315315 const ret = [ ] ;
316- // Example:
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 , . ] + ) \) $ / ;
316+ const reExtract = / ^ t e s t ( .+ ) \s + \. \. \. b e n c h : \s + ( [ 0 - 9 , . ] + ) ( \w + \/ \w + ) \( \+ \/ - ( [ 0 - 9 , . ] + ) \) $ / ;
319317 const reComma = / , / g;
320318
321319 for ( const line of lines ) {
@@ -326,13 +324,14 @@ function extractCargoResult(output: string): BenchmarkResult[] {
326324
327325 const name = m [ 1 ] . trim ( ) ;
328326 const value = parseFloat ( m [ 2 ] . replace ( reComma , '' ) ) ;
329- const range = m [ 3 ] . replace ( reComma , '' ) ;
327+ const unit = m [ 3 ] . trim ( ) ;
328+ const range = m [ 4 ] . replace ( reComma , '' ) ;
330329
331330 ret . push ( {
332331 name,
333332 value,
334333 range : `± ${ range } ` ,
335- unit : 'ns/iter' ,
334+ unit : unit ,
336335 } ) ;
337336 }
338337
Original file line number Diff line number Diff line change @@ -134,6 +134,53 @@ exports[`extractResult() extracts benchmark output from cargo - cargo_output.txt
134134}
135135` ;
136136
137+ exports [` extractResult() extracts benchmark output from cargo - cargo_output_units.txt 1` ] = `
138+ {
139+ " benches" : [
140+ {
141+ " name" : " cmov" ,
142+ " range" : " ± 14" ,
143+ " unit" : " cycles/iter" ,
144+ " value" : 2835 ,
145+ },
146+ {
147+ " name" : " cmov2" ,
148+ " range" : " ± 19" ,
149+ " unit" : " cycles/iter" ,
150+ " value" : 2845 ,
151+ },
152+ {
153+ " name" : " mov" ,
154+ " range" : " ± 17" ,
155+ " unit" : " cycles/iter" ,
156+ " value" : 1508 ,
157+ },
158+ {
159+ " name" : " upload" ,
160+ " range" : " ± 420" ,
161+ " unit" : " MS/s" ,
162+ " value" : 1911 ,
163+ },
164+ {
165+ " name" : " download" ,
166+ " range" : " ± 69" ,
167+ " unit" : " MS/s" ,
168+ " value" : 9001 ,
169+ },
170+ ],
171+ " commit" : {
172+ " author" : null ,
173+ " committer" : null ,
174+ " id" : " 123456789abcdef" ,
175+ " message" : " this is dummy" ,
176+ " timestamp" : " dummy timestamp" ,
177+ " url" : " https://github.com/dummy/repo" ,
178+ },
179+ " date" : 1712131503296 ,
180+ " tool" : " cargo" ,
181+ }
182+ ` ;
183+
137184exports [` extractResult() extracts benchmark output from cargo - cargo_output2.txt 1` ] = `
138185{
139186 " benches" : [
Original file line number Diff line number Diff line change 1+ test cmov ... bench: 2835 cycles/iter (+/- 14)
2+
3+ test cmov2 ... bench: 2845 cycles/iter (+/- 19)
4+
5+ test mov ... bench: 1508 cycles/iter (+/- 17)
6+
7+ test upload ... bench: 1911 MS/s (+/- 420)
8+
9+ test download ... bench: 9001 MS/s (+/- 69)
Original file line number Diff line number Diff line change @@ -71,6 +71,10 @@ describe('extractResult()', function () {
7171 tool : 'cargo' ,
7272 file : 'cargo_output3.txt' ,
7373 } ,
74+ {
75+ tool : 'cargo' ,
76+ file : 'cargo_output_units.txt' ,
77+ } ,
7478 {
7579 tool : 'cargo' ,
7680 file : 'criterion_output.txt' ,
You can’t perform that action at this time.
0 commit comments