File tree 4 files changed +64
-5
lines changed
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> {
313
313
function extractCargoResult ( output : string ) : BenchmarkResult [ ] {
314
314
const lines = output . split ( / \r ? \n / g) ;
315
315
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 , . ] + ) \) $ / ;
319
317
const reComma = / , / g;
320
318
321
319
for ( const line of lines ) {
@@ -326,13 +324,14 @@ function extractCargoResult(output: string): BenchmarkResult[] {
326
324
327
325
const name = m [ 1 ] . trim ( ) ;
328
326
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 , '' ) ;
330
329
331
330
ret . push ( {
332
331
name,
333
332
value,
334
333
range : `± ${ range } ` ,
335
- unit : 'ns/iter' ,
334
+ unit : unit ,
336
335
} ) ;
337
336
}
338
337
Original file line number Diff line number Diff line change @@ -134,6 +134,53 @@ exports[`extractResult() extracts benchmark output from cargo - cargo_output.txt
134
134
}
135
135
` ;
136
136
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
+
137
184
exports [` extractResult() extracts benchmark output from cargo - cargo_output2.txt 1` ] = `
138
185
{
139
186
" 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 () {
71
71
tool : 'cargo' ,
72
72
file : 'cargo_output3.txt' ,
73
73
} ,
74
+ {
75
+ tool : 'cargo' ,
76
+ file : 'cargo_output_units.txt' ,
77
+ } ,
74
78
{
75
79
tool : 'cargo' ,
76
80
file : 'criterion_output.txt' ,
You can’t perform that action at this time.
0 commit comments