From 09ae512ccb4d8a36a0c6c1a700b48fdd3f9fc6c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Fri, 11 Mar 2022 23:07:02 +0100 Subject: feat: "deno bench" subcommand (#13713) This commit adds "deno bench" subcommand and "Deno.bench()" API that allows to register bench cases. The API is modelled after "Deno.test()" and "deno test" subcommand. Currently the output is rudimentary and bench cases and not subject to "ops" and "resource" sanitizers. Co-authored-by: evan --- cli/main.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'cli/main.rs') diff --git a/cli/main.rs b/cli/main.rs index 916070a83..b1ab5bc8f 100644 --- a/cli/main.rs +++ b/cli/main.rs @@ -40,6 +40,7 @@ mod windows_util; use crate::file_fetcher::File; use crate::file_watcher::ResolutionResult; +use crate::flags::BenchFlags; use crate::flags::BundleFlags; use crate::flags::CacheFlags; use crate::flags::CheckFlag; @@ -1248,6 +1249,19 @@ async fn coverage_command( Ok(0) } +async fn bench_command( + flags: Flags, + bench_flags: BenchFlags, +) -> Result { + if flags.watch.is_some() { + tools::bench::run_benchmarks_with_watch(flags, bench_flags).await?; + } else { + tools::bench::run_benchmarks(flags, bench_flags).await?; + } + + Ok(0) +} + async fn test_command( flags: Flags, test_flags: TestFlags, @@ -1328,6 +1342,9 @@ fn get_subcommand( flags: Flags, ) -> Pin>>> { match flags.subcommand.clone() { + DenoSubcommand::Bench(bench_flags) => { + bench_command(flags, bench_flags).boxed_local() + } DenoSubcommand::Bundle(bundle_flags) => { bundle_command(flags, bundle_flags).boxed_local() } -- cgit v1.2.3