diff options
author | Bartek Iwańczuk <biwanczuk@gmail.com> | 2023-08-02 01:55:23 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-01 23:55:23 +0000 |
commit | 36ae37604a0ddab4349df6eb6fafb8ae39fd20fc (patch) | |
tree | bf2530f8e7d2a7afa58a3f29900cb0721efc97c4 | |
parent | fec34d8069517be195193cd3578e7988d39fd0e1 (diff) |
feat(bench): print iter/s in the report (#19994)
This commit adds "iter/s" column to the console report
generated by "deno bench" subcommand.
29 files changed, 142 insertions, 70 deletions
diff --git a/cli/tests/testdata/bench/allow_all.out b/cli/tests/testdata/bench/allow_all.out index c4a60fcf5..b118856e9 100644 --- a/cli/tests/testdata/bench/allow_all.out +++ b/cli/tests/testdata/bench/allow_all.out @@ -3,8 +3,8 @@ cpu: [WILDCARD] runtime: deno [WILDCARD] ([WILDCARD]) [WILDCARD]/bench/allow_all.ts -benchmark time (avg) (min … max) p75 p99 p995 ----------------------------------------------------- ----------------------------- +benchmark time (avg) iter/s (min … max) p75 p99 p995 +------------------------------------------------------------------ ----------------------------- read false [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] read true [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] write false [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] diff --git a/cli/tests/testdata/bench/allow_none.out b/cli/tests/testdata/bench/allow_none.out index 3fd649ebe..7c443075b 100644 --- a/cli/tests/testdata/bench/allow_none.out +++ b/cli/tests/testdata/bench/allow_none.out @@ -3,8 +3,8 @@ cpu: [WILDCARD] runtime: deno [WILDCARD] ([WILDCARD]) [WILDCARD]/bench/allow_none.ts -benchmark time (avg) (min … max) p75 p99 p995 -------------------------------------------------- ----------------------------- +benchmark time (avg) iter/s (min … max) p75 p99 p995 +--------------------------------------------------------------- ----------------------------- read error: PermissionDenied: Can't escalate parent thread permissions [WILDCARD] write error: PermissionDenied: Can't escalate parent thread permissions diff --git a/cli/tests/testdata/bench/before_unload_prevent_default.out b/cli/tests/testdata/bench/before_unload_prevent_default.out index 916681625..dcb6d8194 100644 --- a/cli/tests/testdata/bench/before_unload_prevent_default.out +++ b/cli/tests/testdata/bench/before_unload_prevent_default.out @@ -2,6 +2,6 @@ cpu: [WILDCARD] runtime: deno [WILDCARD] [WILDCARD]/before_unload_prevent_default.ts -benchmark time (avg) (min … max) p75 p99 p995 -------------------------------------------------- ----------------------------- +benchmark time (avg) iter/s (min … max) p75 p99 p995 +--------------------------------------------------------------- ----------------------------- foo [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] diff --git a/cli/tests/testdata/bench/bench_formatting.out b/cli/tests/testdata/bench/bench_formatting.out index 9539e712f..5e3eed1cd 100644 --- a/cli/tests/testdata/bench/bench_formatting.out +++ b/cli/tests/testdata/bench/bench_formatting.out @@ -3,6 +3,6 @@ cpu: [WILDCARD] runtime: deno [WILDCARD] ([WILDCARD]) [WILDCARD]/bench/bench_formatting.ts -benchmark time (avg) (min … max) p75 p99 p995 -------------------------------------------------- ----------------------------- +benchmark time (avg) iter/s (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/check_local_by_default.out b/cli/tests/testdata/bench/check_local_by_default.out index 971c098bd..4fc2f2a68 100644 --- a/cli/tests/testdata/bench/check_local_by_default.out +++ b/cli/tests/testdata/bench/check_local_by_default.out @@ -1,5 +1,5 @@ [WILDCARD] [WILDCARD]/bench/check_local_by_default.ts -benchmark time (avg) (min … max) p75 p99 p995 -------------------------------------------------- ----------------------------- +benchmark time (avg) iter/s (min … max) p75 p99 p995 +--------------------------------------------------------------- ----------------------------- diff --git a/cli/tests/testdata/bench/clear_timeout.out b/cli/tests/testdata/bench/clear_timeout.out index b66c49718..fe17b4ae3 100644 --- a/cli/tests/testdata/bench/clear_timeout.out +++ b/cli/tests/testdata/bench/clear_timeout.out @@ -3,8 +3,8 @@ cpu: [WILDCARD] runtime: deno [WILDCARD] ([WILDCARD]) [WILDCARD]/bench/clear_timeout.ts -benchmark time (avg) (min … max) p75 p99 p995 -------------------------------------------------- ----------------------------- +benchmark time (avg) iter/s (min … max) p75 p99 p995 +--------------------------------------------------------------- ----------------------------- bench1 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] bench2 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] bench3 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] diff --git a/cli/tests/testdata/bench/collect.out b/cli/tests/testdata/bench/collect.out index a7adc2b58..016adaf9d 100644 --- a/cli/tests/testdata/bench/collect.out +++ b/cli/tests/testdata/bench/collect.out @@ -5,13 +5,13 @@ cpu: [WILDCARD] runtime: deno [WILDCARD] ([WILDCARD]) [WILDCARD]/bench/collect/bench.ts -benchmark time (avg) (min … max) p75 p99 p995 -------------------------------------------------- ----------------------------- +benchmark time (avg) iter/s (min … max) p75 p99 p995 +--------------------------------------------------------------- ----------------------------- [WILDCARD]/bench/collect/include/2_bench.ts -benchmark time (avg) (min … max) p75 p99 p995 -------------------------------------------------- ----------------------------- +benchmark time (avg) iter/s (min … max) p75 p99 p995 +--------------------------------------------------------------- ----------------------------- [WILDCARD]/bench/collect/include/bench.ts -benchmark time (avg) (min … max) p75 p99 p995 -------------------------------------------------- ----------------------------- +benchmark time (avg) iter/s (min … max) p75 p99 p995 +--------------------------------------------------------------- ----------------------------- diff --git a/cli/tests/testdata/bench/collect2.out b/cli/tests/testdata/bench/collect2.out index e5bb0f1c5..112abb126 100644 --- a/cli/tests/testdata/bench/collect2.out +++ b/cli/tests/testdata/bench/collect2.out @@ -4,9 +4,9 @@ cpu: [WILDCARD] runtime: deno [WILDCARD] ([WILDCARD]) [WILDCARD]/bench/collect/bench.ts -benchmark time (avg) (min … max) p75 p99 p995 -------------------------------------------------- ----------------------------- +benchmark time (avg) iter/s (min … max) p75 p99 p995 +--------------------------------------------------------------- ----------------------------- [WILDCARD]/bench/collect/include/bench.ts -benchmark time (avg) (min … max) p75 p99 p995 -------------------------------------------------- ----------------------------- +benchmark time (avg) iter/s (min … max) p75 p99 p995 +--------------------------------------------------------------- ----------------------------- diff --git a/cli/tests/testdata/bench/exit_sanitizer.out b/cli/tests/testdata/bench/exit_sanitizer.out index ba063642d..501b9ce8a 100644 --- a/cli/tests/testdata/bench/exit_sanitizer.out +++ b/cli/tests/testdata/bench/exit_sanitizer.out @@ -3,8 +3,8 @@ cpu: [WILDCARD] runtime: deno [WILDCARD] ([WILDCARD]) [WILDCARD]/bench/exit_sanitizer.ts -benchmark time (avg) (min … max) p75 p99 p995 -------------------------------------------------- ----------------------------- +benchmark time (avg) iter/s (min … max) p75 p99 p995 +--------------------------------------------------------------- ----------------------------- exit(0) error: AssertionError: Bench attempted to exit with exit code: 0 [WILDCARD] exit(1) error: AssertionError: Bench attempted to exit with exit code: 1 diff --git a/cli/tests/testdata/bench/explicit_start_and_end.out b/cli/tests/testdata/bench/explicit_start_and_end.out index 89df85a42..fa118540c 100644 --- a/cli/tests/testdata/bench/explicit_start_and_end.out +++ b/cli/tests/testdata/bench/explicit_start_and_end.out @@ -2,8 +2,8 @@ cpu: [WILDCARD] runtime: deno [WILDCARD] ([WILDCARD]) [WILDCARD]/explicit_start_and_end.ts -benchmark time (avg) (min … max) p75 p99 p995 ------------------------------------------------------ ----------------------------- +benchmark time (avg) iter/s (min … max) p75 p99 p995 +------------------------------------------------------------------- ----------------------------- start and end [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] start only [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] end only [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] diff --git a/cli/tests/testdata/bench/fail.out b/cli/tests/testdata/bench/fail.out index cc92a08b4..ff3c29b92 100644 --- a/cli/tests/testdata/bench/fail.out +++ b/cli/tests/testdata/bench/fail.out @@ -3,8 +3,8 @@ cpu: [WILDCARD] runtime: deno [WILDCARD] ([WILDCARD]) [WILDCARD]/bench/fail.ts -benchmark time (avg) (min … max) p75 p99 p995 -------------------------------------------------- ----------------------------- +benchmark time (avg) iter/s (min … max) p75 p99 p995 +--------------------------------------------------------------- ----------------------------- bench0 error: Error [WILDCARD] bench1 error: Error diff --git a/cli/tests/testdata/bench/file_protocol.out b/cli/tests/testdata/bench/file_protocol.out index 5a384e1fa..7086c861c 100644 --- a/cli/tests/testdata/bench/file_protocol.out +++ b/cli/tests/testdata/bench/file_protocol.out @@ -3,6 +3,6 @@ cpu: [WILDCARD] runtime: deno [WILDCARD] ([WILDCARD]) [WILDCARD]/bench/file_protocol.ts -benchmark time (avg) (min … max) p75 p99 p995 -------------------------------------------------- ----------------------------- +benchmark time (avg) iter/s (min … max) p75 p99 p995 +--------------------------------------------------------------- ----------------------------- bench0 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] diff --git a/cli/tests/testdata/bench/filter.out b/cli/tests/testdata/bench/filter.out index 3356ded99..970171e0b 100644 --- a/cli/tests/testdata/bench/filter.out +++ b/cli/tests/testdata/bench/filter.out @@ -5,16 +5,16 @@ cpu: [WILDCARD] runtime: deno [WILDCARD] ([WILDCARD]) [WILDCARD]/bench/filter/a_bench.ts -benchmark time (avg) (min … max) p75 p99 p995 -------------------------------------------------- ----------------------------- +benchmark time (avg) iter/s (min … max) p75 p99 p995 +--------------------------------------------------------------- ----------------------------- foo [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] [WILDCARD]/bench/filter/b_bench.ts -benchmark time (avg) (min … max) p75 p99 p995 -------------------------------------------------- ----------------------------- +benchmark time (avg) iter/s (min … max) p75 p99 p995 +--------------------------------------------------------------- ----------------------------- foo [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] [WILDCARD]/bench/filter/c_bench.ts -benchmark time (avg) (min … max) p75 p99 p995 -------------------------------------------------- ----------------------------- +benchmark time (avg) iter/s (min … max) p75 p99 p995 +--------------------------------------------------------------- ----------------------------- foo [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] diff --git a/cli/tests/testdata/bench/finally_timeout.out b/cli/tests/testdata/bench/finally_timeout.out index ec91900aa..96bec017d 100644 --- a/cli/tests/testdata/bench/finally_timeout.out +++ b/cli/tests/testdata/bench/finally_timeout.out @@ -3,8 +3,8 @@ cpu: [WILDCARD] runtime: deno [WILDCARD] ([WILDCARD]) [WILDCARD]/bench/finally_timeout.ts -benchmark time (avg) (min … max) p75 p99 p995 -------------------------------------------------- ----------------------------- +benchmark time (avg) iter/s (min … max) p75 p99 p995 +--------------------------------------------------------------- ----------------------------- error error: Error: fail [WILDCARD] success [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] diff --git a/cli/tests/testdata/bench/group_baseline.out b/cli/tests/testdata/bench/group_baseline.out index 7d175ba1b..cafded7da 100644 --- a/cli/tests/testdata/bench/group_baseline.out +++ b/cli/tests/testdata/bench/group_baseline.out @@ -1,6 +1,6 @@ [WILDCARD]/bench/group_baseline.ts -benchmark time (avg) (min … max) p75 p99 p995 ------------------------------------------------------- ----------------------------- +benchmark time (avg) iter/s (min … max) p75 p99 p995 +-------------------------------------------------------------------- ----------------------------- noop [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] noop2 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] diff --git a/cli/tests/testdata/bench/ignore.out b/cli/tests/testdata/bench/ignore.out index e2a35621d..6ac7f2e2b 100644 --- a/cli/tests/testdata/bench/ignore.out +++ b/cli/tests/testdata/bench/ignore.out @@ -3,5 +3,5 @@ cpu: [WILDCARD] runtime: deno [WILDCARD] ([WILDCARD]) [WILDCARD]/bench/ignore.ts -benchmark time (avg) (min … max) p75 p99 p995 -------------------------------------------------- ----------------------------- +benchmark time (avg) iter/s (min … max) p75 p99 p995 +--------------------------------------------------------------- ----------------------------- diff --git a/cli/tests/testdata/bench/ignore_permissions.out b/cli/tests/testdata/bench/ignore_permissions.out index a518c572c..389590a16 100644 --- a/cli/tests/testdata/bench/ignore_permissions.out +++ b/cli/tests/testdata/bench/ignore_permissions.out @@ -3,5 +3,5 @@ cpu: [WILDCARD] runtime: deno [WILDCARD] ([WILDCARD]) [WILDCARD]/bench/ignore_permissions.ts -benchmark time (avg) (min … max) p75 p99 p995 -------------------------------------------------- ----------------------------- +benchmark time (avg) iter/s (min … max) p75 p99 p995 +--------------------------------------------------------------- ----------------------------- diff --git a/cli/tests/testdata/bench/interval.out b/cli/tests/testdata/bench/interval.out index 882821837..c6110f0a5 100644 --- a/cli/tests/testdata/bench/interval.out +++ b/cli/tests/testdata/bench/interval.out @@ -3,5 +3,5 @@ cpu: [WILDCARD] runtime: deno [WILDCARD] ([WILDCARD]) [WILDCARD]/bench/interval.ts -benchmark time (avg) (min … max) p75 p99 p995 -------------------------------------------------- ----------------------------- +benchmark time (avg) iter/s (min … max) p75 p99 p995 +--------------------------------------------------------------- ----------------------------- diff --git a/cli/tests/testdata/bench/load_unload.out b/cli/tests/testdata/bench/load_unload.out index 6537f47fa..e5bc6b29e 100644 --- a/cli/tests/testdata/bench/load_unload.out +++ b/cli/tests/testdata/bench/load_unload.out @@ -3,6 +3,6 @@ cpu: [WILDCARD] runtime: deno [WILDCARD] ([WILDCARD]) [WILDCARD]/bench/load_unload.ts -benchmark time (avg) (min … max) p75 p99 p995 -------------------------------------------------- ----------------------------- +benchmark time (avg) iter/s (min … max) p75 p99 p995 +--------------------------------------------------------------- ----------------------------- bench [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] diff --git a/cli/tests/testdata/bench/meta.out b/cli/tests/testdata/bench/meta.out index 85b898e7e..beba58df7 100644 --- a/cli/tests/testdata/bench/meta.out +++ b/cli/tests/testdata/bench/meta.out @@ -5,5 +5,5 @@ cpu: [WILDCARD] runtime: deno [WILDCARD] ([WILDCARD]) [WILDCARD]/bench/meta.ts -benchmark time (avg) (min … max) p75 p99 p995 -------------------------------------------------- ----------------------------- +benchmark time (avg) iter/s (min … max) p75 p99 p995 +--------------------------------------------------------------- ----------------------------- diff --git a/cli/tests/testdata/bench/multifile_summary.out b/cli/tests/testdata/bench/multifile_summary.out index 6a8a12102..d4e1157ec 100644 --- a/cli/tests/testdata/bench/multifile_summary.out +++ b/cli/tests/testdata/bench/multifile_summary.out @@ -5,8 +5,8 @@ cpu: [WILDCARD] runtime: deno [WILDCARD] ([WILDCARD]) [WILDCARD]/bench/group_baseline.ts -benchmark time (avg) (min … max) p75 p99 p995 ------------------------------------------------------- ----------------------------- +benchmark time (avg) iter/s (min … max) p75 p99 p995 +-------------------------------------------------------------------- ----------------------------- noop [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] noop2 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] @@ -24,8 +24,8 @@ summary [WILDCARD]x faster than parse url 200x [WILDCARD]/bench/pass.ts -benchmark time (avg) (min … max) p75 p99 p995 -------------------------------------------------- ----------------------------- +benchmark time (avg) iter/s (min … max) p75 p99 p995 +--------------------------------------------------------------- ----------------------------- bench0 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] bench1 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] bench2 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] @@ -38,8 +38,8 @@ bench8 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD bench9 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] [WILDCARD]/bench/group_baseline.ts -benchmark time (avg) (min … max) p75 p99 p995 ------------------------------------------------------- ----------------------------- +benchmark time (avg) iter/s (min … max) p75 p99 p995 +-------------------------------------------------------------------- ----------------------------- noop [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] noop2 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] diff --git a/cli/tests/testdata/bench/no_prompt_by_default.out b/cli/tests/testdata/bench/no_prompt_by_default.out index a73971a9b..4c7e7f146 100644 --- a/cli/tests/testdata/bench/no_prompt_by_default.out +++ b/cli/tests/testdata/bench/no_prompt_by_default.out @@ -2,8 +2,8 @@ runtime: deno [WILDCARD] ([WILDCARD]) [WILDCARD]/bench/no_prompt_by_default.ts -benchmark time (avg) (min … max) p75 p99 p995 -------------------------------------------------- ----------------------------- +benchmark time (avg) iter/s (min … max) p75 p99 p995 +--------------------------------------------------------------- ----------------------------- no prompt error: PermissionDenied: Requires read access to "./some_file.txt", run again with the --allow-read flag [WILDCARD] error: Bench failed diff --git a/cli/tests/testdata/bench/no_prompt_with_denied_perms.out b/cli/tests/testdata/bench/no_prompt_with_denied_perms.out index fe8f0c29c..74400dafe 100644 --- a/cli/tests/testdata/bench/no_prompt_with_denied_perms.out +++ b/cli/tests/testdata/bench/no_prompt_with_denied_perms.out @@ -2,8 +2,8 @@ runtime: deno [WILDCARD] ([WILDCARD]) [WILDCARD]/bench/no_prompt_with_denied_perms.ts -benchmark time (avg) (min … max) p75 p99 p995 -------------------------------------------------- ----------------------------- +benchmark time (avg) iter/s (min … max) p75 p99 p995 +--------------------------------------------------------------- ----------------------------- no prompt error: PermissionDenied: Requires read access to "./some_file.txt", run again with the --allow-read flag [WILDCARD] error: Bench failed diff --git a/cli/tests/testdata/bench/only.out b/cli/tests/testdata/bench/only.out index b874c9a96..00338af8e 100644 --- a/cli/tests/testdata/bench/only.out +++ b/cli/tests/testdata/bench/only.out @@ -3,7 +3,7 @@ cpu: [WILDCARD] runtime: deno [WILDCARD] ([WILDCARD]) [WILDCARD]/bench/only.ts -benchmark time (avg) (min … max) p75 p99 p995 -------------------------------------------------- ----------------------------- +benchmark time (avg) iter/s (min … max) p75 p99 p995 +--------------------------------------------------------------- ----------------------------- only [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] error: Bench failed because the "only" option was used diff --git a/cli/tests/testdata/bench/overloads.out b/cli/tests/testdata/bench/overloads.out index 347a8392d..289c8dde6 100644 --- a/cli/tests/testdata/bench/overloads.out +++ b/cli/tests/testdata/bench/overloads.out @@ -3,8 +3,8 @@ cpu: [WILDCARD] runtime: deno [WILDCARD] ([WILDCARD]) [WILDCARD]/bench/overloads.ts -benchmark time (avg) (min … max) p75 p99 p995 -------------------------------------------------- ----------------------------- +benchmark time (avg) iter/s (min … max) p75 p99 p995 +--------------------------------------------------------------- ----------------------------- bench0 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] bench1 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] bench2 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] diff --git a/cli/tests/testdata/bench/pass.out b/cli/tests/testdata/bench/pass.out index 9090b5535..19ea6fd13 100644 --- a/cli/tests/testdata/bench/pass.out +++ b/cli/tests/testdata/bench/pass.out @@ -3,8 +3,8 @@ cpu: [WILDCARD] runtime: deno [WILDCARD] ([WILDCARD]) [WILDCARD]/bench/pass.ts -benchmark time (avg) (min … max) p75 p99 p995 -------------------------------------------------- ----------------------------- +benchmark time (avg) iter/s (min … max) p75 p99 p995 +--------------------------------------------------------------- ----------------------------- bench0 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] bench1 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] bench2 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] diff --git a/cli/tests/testdata/bench/quiet.out b/cli/tests/testdata/bench/quiet.out index aad853189..ed9e06c84 100644 --- a/cli/tests/testdata/bench/quiet.out +++ b/cli/tests/testdata/bench/quiet.out @@ -2,8 +2,8 @@ cpu: [WILDCARD] runtime: deno [WILDCARD] ([WILDCARD]) [WILDCARD]/bench/quiet.ts -benchmark time (avg) (min … max) p75 p99 p995 ------------------------------------------------------ ----------------------------- +benchmark time (avg) iter/s (min … max) p75 p99 p995 +------------------------------------------------------------------- ----------------------------- console.log [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] console.error [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] console.info [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] diff --git a/cli/tests/testdata/package_json/basic/lib.bench.out b/cli/tests/testdata/package_json/basic/lib.bench.out index b16d9e7ac..fa9c5efc6 100644 --- a/cli/tests/testdata/package_json/basic/lib.bench.out +++ b/cli/tests/testdata/package_json/basic/lib.bench.out @@ -7,5 +7,5 @@ runtime: [WILDCARD] file:///[WILDCARD]/lib.bench.ts [WILDCARD] --------------------------------------------------- ----------------------------- +---------------------------------------------------------------- ----------------------------- should add [WILDCARD] diff --git a/cli/tools/bench/mitata.rs b/cli/tools/bench/mitata.rs index 14634233b..9049b6462 100644 --- a/cli/tools/bench/mitata.rs +++ b/cli/tools/bench/mitata.rs @@ -9,6 +9,72 @@ use crate::colors; use std::str::FromStr; +fn avg_to_iter_per_s(time: f64) -> String { + let iter_per_s = 1e9 / time; + let (decimals, fractional) = into_decimal_and_fractional_parts(iter_per_s); + human_readable_decimal_with_fractional(decimals, fractional) +} + +/// Return a tuple representing decimal part of provided float, as well as its +/// first fractional digit. +fn into_decimal_and_fractional_parts(num: f64) -> (i64, i64) { + let decimal_part = num.floor(); + let fractional_part = { + let decs = ((num - num.floor()) * 10.0).round(); + if decs == 10.0 { + 0 + } else { + decs as i64 + } + }; + (decimal_part as i64, fractional_part) +} + +fn human_readable_decimal_with_fractional( + decimal: i64, + fractional: i64, +) -> String { + // Sweet one-liner to separate integer by commas from: + // https://stackoverflow.com/a/67834588/21759102 + let fmt_decimal = decimal + .to_string() + .as_bytes() + .rchunks(3) + .rev() + .map(std::str::from_utf8) + .collect::<Result<Vec<&str>, _>>() + .unwrap() + .join(","); + + format!("{}.{}", fmt_decimal, fractional) +} + +#[test] +fn test_into_decimal_and_fractional_parts() { + assert_eq!(into_decimal_and_fractional_parts(10.0), (10, 0)); + assert_eq!(into_decimal_and_fractional_parts(10.1), (10, 1)); + assert_eq!(into_decimal_and_fractional_parts(10.2), (10, 2)); + assert_eq!(into_decimal_and_fractional_parts(10.3), (10, 3)); + assert_eq!(into_decimal_and_fractional_parts(10.4), (10, 4)); + assert_eq!(into_decimal_and_fractional_parts(10.5), (10, 5)); + assert_eq!(into_decimal_and_fractional_parts(10.6), (10, 6)); + assert_eq!(into_decimal_and_fractional_parts(10.7), (10, 7)); + assert_eq!(into_decimal_and_fractional_parts(10.8), (10, 8)); + assert_eq!(into_decimal_and_fractional_parts(10.9), (10, 9)); +} + +#[test] +fn test_avg_to_iter_per_s() { + assert_eq!(avg_to_iter_per_s(55.85), "17,905,102.0"); + assert_eq!(avg_to_iter_per_s(64_870_000.0), "15.4"); + assert_eq!(avg_to_iter_per_s(104_370_000.0), "9.6"); + assert_eq!(avg_to_iter_per_s(6_400_000.0), "156.3"); + assert_eq!(avg_to_iter_per_s(46_890_000.0), "21.3"); + assert_eq!(avg_to_iter_per_s(100_000_000.0), "10.0"); + assert_eq!(avg_to_iter_per_s(1_000_000_000.0), "1.0"); + assert_eq!(avg_to_iter_per_s(5_920_000_000.0), "0.2"); +} + pub fn fmt_duration(time: f64) -> String { // SAFETY: this is safe since its just reformatting numbers unsafe { @@ -194,7 +260,10 @@ pub mod reporter { let mut s = String::new(); s.push_str(&"-".repeat( - options.size + 14 * options.avg as usize + 24 * options.min_max as usize, + options.size + + 14 * options.avg as usize + + 14 * options.avg as usize + + 24 * options.min_max as usize, )); if options.percentiles { @@ -239,6 +308,7 @@ pub mod reporter { s.push_str(&format!("{:<size$}", "benchmark")); if options.avg { s.push_str(&format!("{:>14}", "time (avg)")); + s.push_str(&format!("{:>14}", "iter/s")); } if options.min_max { s.push_str(&format!("{:>24}", "(min … max)")); @@ -266,6 +336,7 @@ pub mod reporter { "{:>14}", format!("{}/iter", fmt_duration(stats.avg)) )); + s.push_str(&format!("{:>14}", avg_to_iter_per_s(stats.avg))); } if options.min_max { s.push_str(&format!( @@ -291,6 +362,7 @@ pub mod reporter { "{:>30}", format!("{}/iter", colors::yellow(fmt_duration(stats.avg))) )); + s.push_str(&format!("{:>14}", avg_to_iter_per_s(stats.avg))); } if options.min_max { s.push_str(&format!( |