Skip to content

Commit

Permalink
chore(cli/bench): Add bun HTTP server (#15004)
Browse files Browse the repository at this point in the history
  • Loading branch information
littledivy authored Jun 29, 2022
1 parent 91570ba commit 5eb9abd
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 2 deletions.
23 changes: 23 additions & 0 deletions cli/bench/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 <path> <port>
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 <path> <addr>
res.insert(
Expand Down
8 changes: 8 additions & 0 deletions cli/bench/http/bun_http.js
Original file line number Diff line number Diff line change
@@ -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),
});
2 changes: 1 addition & 1 deletion test_util/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand Down
2 changes: 1 addition & 1 deletion third_party

0 comments on commit 5eb9abd

Please sign in to comment.