diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2022-03-11 23:07:02 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-11 23:07:02 +0100 |
commit | 09ae512ccb4d8a36a0c6c1a700b48fdd3f9fc6c2 (patch) | |
tree | 90f5bc5a9d48f5279208eecf985dcf7f777e87c5 /cli/main.rs | |
parent | 32c059544be40987a445f13cc3c7ba585f47889e (diff) |
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 <github@evan.lol>
Diffstat (limited to 'cli/main.rs')
-rw-r--r-- | cli/main.rs | 17 |
1 files changed, 17 insertions, 0 deletions
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<i32, AnyError> { + 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<Box<dyn Future<Output = Result<i32, AnyError>>>> { 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() } |