From 5eb9abd65f97e43b50aeb724deb8e3b7847681e9 Mon Sep 17 00:00:00 2001 From: Divy Srivastava Date: Wed, 29 Jun 2022 16:57:19 +0530 Subject: [PATCH] chore(cli/bench): Add bun HTTP server (#15004) --- cli/bench/http.rs | 23 +++++++++++++++++++++++ cli/bench/http/bun_http.js | 8 ++++++++ test_util/src/lib.rs | 2 +- third_party | 2 +- 4 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 cli/bench/http/bun_http.js diff --git a/cli/bench/http.rs b/cli/bench/http.rs index 3735fde1bf..c577e577a2 100644 --- a/cli/bench/http.rs +++ b/cli/bench/http.rs @@ -53,6 +53,29 @@ pub fn benchmark( maybe_lua, )?, ); + } else if name.starts_with("bun") && !cfg!(target_os = "windows") { + // Bun does not support Windows. + #[cfg(target_arch = "x86_64")] + #[cfg(not(target_vendor = "apple"))] + let bun_exe = test_util::prebuilt_tool_path("bun"); + #[cfg(target_vendor = "apple")] + #[cfg(target_arch = "x86_64")] + let bun_exe = test_util::prebuilt_tool_path("bun-x64"); + #[cfg(target_vendor = "apple")] + #[cfg(target_arch = "aarch64")] + let bun_exe = test_util::prebuilt_tool_path("bun-aarch64"); + + // bun + res.insert( + file_stem.to_string(), + run( + &[bun_exe.to_str().unwrap(), path, &port.to_string()], + port, + None, + None, + maybe_lua, + )?, + ); } else { // deno run -A --unstable res.insert( diff --git a/cli/bench/http/bun_http.js b/cli/bench/http/bun_http.js new file mode 100644 index 0000000000..a4cd2c5620 --- /dev/null +++ b/cli/bench/http/bun_http.js @@ -0,0 +1,8 @@ +// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license. +const port = Bun.argv[2] || "4545"; +Bun.serve({ + fetch(_req) { + return new Response("Hello World"); + }, + port: Number(port), +}); diff --git a/test_util/src/lib.rs b/test_util/src/lib.rs index 8df222115f..2b679a4e9c 100644 --- a/test_util/src/lib.rs +++ b/test_util/src/lib.rs @@ -139,7 +139,7 @@ pub fn prebuilt_tool_path(tool: &str) -> PathBuf { prebuilt_path().join(platform_dir_name()).join(exe) } -fn platform_dir_name() -> &'static str { +pub fn platform_dir_name() -> &'static str { if cfg!(target_os = "linux") { "linux64" } else if cfg!(target_os = "macos") { diff --git a/third_party b/third_party index c9954bdb27..6e290feb09 160000 --- a/third_party +++ b/third_party @@ -1 +1 @@ -Subproject commit c9954bdb27cb4a1406d2591df34bc29a1e738ca0 +Subproject commit 6e290feb0936dbeed63f09879a6b234adb81d17b