diff options
author | Mike Mulchrone <mtmulch0191@outlook.com> | 2023-06-07 06:27:25 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-07 12:27:25 +0200 |
commit | 28ce0ef583b1be03f5ec4fdd90b946590862c5d4 (patch) | |
tree | de03b9551983495499ff24008d9650f5ed445334 | |
parent | 42c10ecfdb5b48ef7cf1293ce8d2614d5fae9f33 (diff) |
fix(cli): formatting bench with colors (#19323)
-rw-r--r-- | cli/tests/integration/bench_tests.rs | 6 | ||||
-rw-r--r-- | cli/tests/testdata/bench/bench_formatting.out | 8 | ||||
-rw-r--r-- | cli/tests/testdata/bench/bench_formatting.ts | 3 | ||||
-rw-r--r-- | cli/tools/bench.rs | 6 |
4 files changed, 20 insertions, 3 deletions
diff --git a/cli/tests/integration/bench_tests.rs b/cli/tests/integration/bench_tests.rs index 0fc268076..0ba297e63 100644 --- a/cli/tests/integration/bench_tests.rs +++ b/cli/tests/integration/bench_tests.rs @@ -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, diff --git a/cli/tests/testdata/bench/bench_formatting.out b/cli/tests/testdata/bench/bench_formatting.out new file mode 100644 index 000000000..9539e712f --- /dev/null +++ b/cli/tests/testdata/bench/bench_formatting.out @@ -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]
\ No newline at end of file diff --git a/cli/tests/testdata/bench/bench_formatting.ts b/cli/tests/testdata/bench/bench_formatting.ts new file mode 100644 index 000000000..fdee15abb --- /dev/null +++ b/cli/tests/testdata/bench/bench_formatting.ts @@ -0,0 +1,3 @@ +Deno.bench("Date.now", () => { + Date.now(); +}); diff --git a/cli/tools/bench.rs b/cli/tools/bench.rs index 1a5df92bf..6461e544f 100644 --- a/cli/tools/bench.rs +++ b/cli/tools/bench.rs @@ -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)) |