summaryrefslogtreecommitdiff
path: root/cli/mainrt.rs
diff options
context:
space:
mode:
authorMatt Mastracci <matthew@mastracci.com>2024-03-05 15:14:49 -0700
committerGitHub <noreply@github.com>2024-03-05 15:14:49 -0700
commit3fd4b882a4bd0087ebf112615aafc314bb71e594 (patch)
treedf94e3973815c44d1851dc927f9a3e77144f8286 /cli/mainrt.rs
parent3333d67335091b061c4f538fe888b4f833e18f07 (diff)
perf(cli): faster standalone executable determination (#22717)
This was showing up on the flamegraph. ``` 14:54 $ hyperfine -S none --warmup 25 '/tmp/deno run /tmp/empty.js' 'target/release/deno run /tmp/empty.js' Benchmark 1: /tmp/deno run /tmp/empty.js Time (mean ± σ): 17.2 ms ± 4.7 ms [User: 11.2 ms, System: 4.0 ms] Range (min … max): 15.1 ms … 72.9 ms 172 runs Warning: Statistical outliers were detected. Consider re-running this benchmark on a quiet system without any interferences from other programs. It might help to use the '--warmup' or '--prepare' options. Benchmark 2: target/release/deno run /tmp/empty.js Time (mean ± σ): 16.7 ms ± 1.1 ms [User: 11.1 ms, System: 4.0 ms] Range (min … max): 15.0 ms … 20.1 ms 189 runs Summary 'target/release/deno run /tmp/empty.js' ran 1.03 ± 0.29 times faster than '/tmp/deno run /tmp/empty.js' ✔ ~/Documents/github/deno/deno [faster_extract|…5⚑ 23] ```
Diffstat (limited to 'cli/mainrt.rs')
-rw-r--r--cli/mainrt.rs13
1 files changed, 9 insertions, 4 deletions
diff --git a/cli/mainrt.rs b/cli/mainrt.rs
index 9c7ee3c5c..ae4ea727f 100644
--- a/cli/mainrt.rs
+++ b/cli/mainrt.rs
@@ -69,11 +69,16 @@ fn unwrap_or_exit<T>(result: Result<T, AnyError>) -> T {
fn main() {
let args: Vec<String> = env::args().collect();
+ let current_exe_path = current_exe().unwrap();
+ let standalone =
+ standalone::extract_standalone(&current_exe_path, args.clone());
let future = async move {
- let current_exe_path = current_exe().unwrap();
- match standalone::extract_standalone(&current_exe_path, args).await {
- Ok(Some((metadata, eszip))) => standalone::run(eszip, metadata).await,
- Ok(None) => Err(generic_error("No archive found.")),
+ match standalone {
+ Ok(Some(future)) => {
+ let (metadata, eszip) = future.await?;
+ standalone::run(eszip, metadata).await
+ }
+ Ok(None) => Ok(()),
Err(err) => Err(err),
}
};