Skip to content

Commit

Permalink
fix(cli): formatting bench with colors (#19323)
Browse files Browse the repository at this point in the history
  • Loading branch information
WingZer0o authored Jun 7, 2023
1 parent 42c10ec commit 28ce0ef
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
6 changes: 6 additions & 0 deletions cli/tests/integration/bench_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 43,12 @@ itest!(fail {
output: "bench/fail.out",
});

itest!(bench_formatting {
args: "bench bench/bench_formatting.ts",
exit_code: 0,
output: "bench/bench_formatting.out",
});

itest!(collect {
args: "bench --ignore=bench/collect/ignore bench/collect",
exit_code: 0,
Expand Down
8 changes: 8 additions & 0 deletions cli/tests/testdata/bench/bench_formatting.out
Original file line number Diff line number Diff line change
@@ -0,0 1,8 @@
Check [WILDCARD]/bench/bench_formatting.ts
cpu: [WILDCARD]
runtime: deno [WILDCARD] ([WILDCARD])

[WILDCARD]/bench/bench_formatting.ts
benchmark time (avg) (min … max) p75 p99 p995
------------------------------------------------- -----------------------------
[WILDCARD] [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD]
3 changes: 3 additions & 0 deletions cli/tests/testdata/bench/bench_formatting.ts
Original file line number Diff line number Diff line change
@@ -0,0 1,3 @@
Deno.bench("Date.now", () => {
Date.now();
});
6 changes: 3 additions & 3 deletions cli/tools/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1147,13 1147,13 @@ mod mitata {
} else {
if options.avg {
s.push_str(&format!(
"{:>23}",
"{:>30}",
format!("{}/iter", colors::yellow(fmt_duration(stats.avg)))
));
}
if options.min_max {
s.push_str(&format!(
"{:>42}",
"{:>50}",
format!(
"({} … {})",
colors::cyan(fmt_duration(stats.min)),
Expand All @@ -1163,7 1163,7 @@ mod mitata {
}
if options.percentiles {
s.push_str(&format!(
" {:>18} {:>18} {:>18}",
" {:>22} {:>22} {:>22}",
colors::magenta(fmt_duration(stats.p75)),
colors::magenta(fmt_duration(stats.p99)),
colors::magenta(fmt_duration(stats.p995))
Expand Down

0 comments on commit 28ce0ef

Please sign in to comment.