Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support benchmark results with decimal dot #3

Merged
merged 1 commit into from
Dec 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/extract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,8 @@ function extractBenchmarkJsResult(output: string): BenchmarkResult[] {
const ret = [];
// Example:
// fib(20) x 11,465 ops/sec ±1.12% (91 runs sampled)
const reExtract = /^ x ([0-9,]+)\s+(\S+)\s+((?:±|\+-)[^%]+%) \((\d+) runs sampled\)$/; // Note: Extract parts after benchmark name
// createObjectBuffer with 200 comments x 81.61 ops/sec ±1.70% (69 runs sampled)
const reExtract = /^ x ([0-9,.]+)\s+(\S+)\s+((?:±|\+-)[^%]+%) \((\d+) runs sampled\)$/; // Note: Extract parts after benchmark name
const reComma = /,/g;

for (const line of lines) {
Expand All @@ -218,7 +219,7 @@ function extractBenchmarkJsResult(output: string): BenchmarkResult[] {
continue;
}

const value = parseInt(m[1].replace(reComma, ''), 10);
const value = parseFloat(m[1].replace(reComma, ''));
const unit = m[2];
const range = m[3];
const extra = `${m[4]} samples`;
Expand Down
1 change: 1 addition & 0 deletions test/data/extract/benchmarkjs_output.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
fib(10) x 1,431,759 ops/sec ±0.74% (93 runs sampled)
fib(20) x 12,146 ops/sec ±0.32% (96 runs sampled)
createObjectBuffer with 200 comments x 81.61 ops/sec ±1.70% (69 runs sampled)
7 changes: 7 additions & 0 deletions test/extract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@ describe('extractResult()', function() {
value: 12146,
extra: '96 samples',
},
{
name: 'createObjectBuffer with 200 comments',
range: '±1.70%',
unit: 'ops/sec',
value: 81.61,
extra: '69 samples',
},
],
},
{
Expand Down