diff --git a/src/extract.ts b/src/extract.ts index 870282114..90a74ccdb 100644 --- a/src/extract.ts +++ b/src/extract.ts @@ -273,7 +273,7 @@ function extractCargoResult(output: string): BenchmarkResult[] { continue; } - const name = m[1]; + const name = m[1].trim(); const value = parseInt(m[2].replace(reComma, ''), 10); const range = m[3].replace(reComma, ''); diff --git a/test/data/extract/cargo_output2.txt b/test/data/extract/cargo_output2.txt new file mode 100644 index 000000000..c75146d34 --- /dev/null +++ b/test/data/extract/cargo_output2.txt @@ -0,0 +1,4 @@ +test bench_engine_new ... bench: 211,834 ns/iter (+/- 70,126) +test bench_engine_new_raw ... bench: 197 ns/iter (+/- 18) +test bench_engine_new_raw_core ... bench: 196 ns/iter (+/- 31) +test bench_engine_register_fn ... bench: 493 ns/iter (+/- 82) diff --git a/test/extract.spec.ts b/test/extract.spec.ts index 20848960e..c6e9b06aa 100644 --- a/test/extract.spec.ts +++ b/test/extract.spec.ts @@ -73,6 +73,36 @@ describe('extractResult()', function () { }, ], }, + { + tool: 'cargo', + file: 'cargo_output2.txt', + expected: [ + { + name: 'bench_engine_new', + range: '± 70126', + unit: 'ns/iter', + value: 211834, + }, + { + name: 'bench_engine_new_raw', + range: '± 18', + unit: 'ns/iter', + value: 197, + }, + { + name: 'bench_engine_new_raw_core', + range: '± 31', + unit: 'ns/iter', + value: 196, + }, + { + name: 'bench_engine_register_fn', + range: '± 82', + unit: 'ns/iter', + value: 493, + }, + ], + }, { tool: 'cargo', file: 'criterion_output.txt', @@ -346,7 +376,7 @@ describe('extractResult()', function () { ]; for (const test of normalCases) { - it(`extracts benchmark output from ${test.tool}`, async function () { + it(`extracts benchmark output from ${test.tool}${test.file ? ` - ${test.file}` : ''}`, async function () { const file = test.file ?? `${test.tool}_output.txt`; const outputFilePath = path.join(__dirname, 'data', 'extract', file); const config = {