fix(cli): formatting bench with colors (#19323)

This commit is contained in:
Mike Mulchrone 2023-06-07 06:27:25 -04:00 committed by GitHub
parent 42c10ecfdb
commit 28ce0ef583
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 3 deletions

View file

@ -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,

View file

@ -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]

View file

@ -0,0 +1,3 @@
Deno.bench("Date.now", () => {
Date.now();
});

View file

@ -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)),
@ -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))