Skip to content

Commit

Permalink
refactor: code cleanups
Browse files Browse the repository at this point in the history
Signed-off-by: Jérôme Benoit <[email protected]>
  • Loading branch information
jerome-benoit committed Apr 7, 2024
1 parent 63e7bf4 commit 23ff114
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
10 changes: 6 additions & 4 deletions src/cli.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,9 @@ export async function run(opts = {}) {
if (!opts.json)
log(table.benchmark(benchmark.name, benchmark.stats, opts));
} catch (err) {
benchmark.error = { stack: err.stack, message: err.message };
if (!opts.json) log(table.benchmarkError(benchmark.name, err, opts));
benchmark.error = err;
if (!opts.json)
log(table.benchmarkError(benchmark.name, benchmark.error, opts));
}
}

Expand Down Expand Up @@ -238,8 +239,9 @@ export async function run(opts = {}) {
if (!opts.json)
log(table.benchmark(benchmark.name, benchmark.stats, opts));
} catch (err) {
benchmark.error = { stack: err.stack, message: err.message };
if (!opts.json) log(table.benchmarkError(benchmark.name, err, opts));
benchmark.error = err;
if (!opts.json)
log(table.benchmarkError(benchmark.name, benchmark.error, opts));
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/reporter/table.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import * as clr from './clr.mjs';
import { duration } from './fmt.mjs';

export function size(names) {
let max = 9;
for (const name of names) if (max < name.length) max = name.length;
let size = 9;
for (const name of names) if (size < name.length) size = name.length;

return 2 + max;
return 2 + size;
}

export function br({
Expand Down

0 comments on commit 23ff114

Please sign in to comment.