1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-24 08:09:08 -05:00

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

This commit is contained in:
Mike Mulchrone 2023-06-07 06:27:25 -04:00 committed by Bartek Iwańczuk
parent e7468b947b
commit 82c3a56674
No known key found for this signature in database
GPG key ID: 0C6BCDDC3B3AD750
4 changed files with 20 additions and 3 deletions

View file

@ -43,6 +43,12 @@ itest!(fail {
output: "bench/fail.out", output: "bench/fail.out",
}); });
itest!(bench_formatting {
args: "bench bench/bench_formatting.ts",
exit_code: 0,
output: "bench/bench_formatting.out",
});
itest!(collect { itest!(collect {
args: "bench --ignore=bench/collect/ignore bench/collect", args: "bench --ignore=bench/collect/ignore bench/collect",
exit_code: 0, 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 { } else {
if options.avg { if options.avg {
s.push_str(&format!( s.push_str(&format!(
"{:>23}", "{:>30}",
format!("{}/iter", colors::yellow(fmt_duration(stats.avg))) format!("{}/iter", colors::yellow(fmt_duration(stats.avg)))
)); ));
} }
if options.min_max { if options.min_max {
s.push_str(&format!( s.push_str(&format!(
"{:>42}", "{:>50}",
format!( format!(
"({} … {})", "({} … {})",
colors::cyan(fmt_duration(stats.min)), colors::cyan(fmt_duration(stats.min)),
@ -1163,7 +1163,7 @@ mod mitata {
} }
if options.percentiles { if options.percentiles {
s.push_str(&format!( s.push_str(&format!(
" {:>18} {:>18} {:>18}", " {:>22} {:>22} {:>22}",
colors::magenta(fmt_duration(stats.p75)), colors::magenta(fmt_duration(stats.p75)),
colors::magenta(fmt_duration(stats.p99)), colors::magenta(fmt_duration(stats.p99)),
colors::magenta(fmt_duration(stats.p995)) colors::magenta(fmt_duration(stats.p995))