summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cli/bench/deno_http_proxy.ts20
-rw-r--r--cli/bench/deno_tcp_proxy.ts35
-rw-r--r--cli/bench/http.rs100
-rw-r--r--cli/bench/main.rs16
-rw-r--r--cli/bench/node_http_proxy.js22
-rw-r--r--cli/bench/throughput.rs63
6 files changed, 0 insertions, 256 deletions
diff --git a/cli/bench/deno_http_proxy.ts b/cli/bench/deno_http_proxy.ts
deleted file mode 100644
index 7295baff5..000000000
--- a/cli/bench/deno_http_proxy.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
-import { serve, ServerRequest } from "../test_util/std/http/server_legacy.ts";
-
-const addr = Deno.args[0] || "127.0.0.1:4500";
-const originAddr = Deno.args[1] || "127.0.0.1:4501";
-const server = serve(addr);
-
-async function proxyRequest(req: ServerRequest): Promise<void> {
- const url = `http://${originAddr}${req.url}`;
- const resp = await fetch(url, {
- method: req.method,
- headers: req.headers,
- });
- req.respond(resp);
-}
-
-console.log(`Proxy listening on http://${addr}/`);
-for await (const req of server) {
- proxyRequest(req);
-}
diff --git a/cli/bench/deno_tcp_proxy.ts b/cli/bench/deno_tcp_proxy.ts
deleted file mode 100644
index df74de8c4..000000000
--- a/cli/bench/deno_tcp_proxy.ts
+++ /dev/null
@@ -1,35 +0,0 @@
-// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
-// Used for benchmarking Deno's tcp proxy performance.
-import { copy } from "../../test_util/std/io/util.ts";
-
-const addr = Deno.args[0] || "127.0.0.1:4500";
-const originAddr = Deno.args[1] || "127.0.0.1:4501";
-
-const [hostname, port] = addr.split(":");
-const [originHostname, originPort] = originAddr.split(":");
-
-const listener = Deno.listen({ hostname, port: Number(port) });
-
-async function handle(conn: Deno.Conn): Promise<void> {
- const origin = await Deno.connect({
- hostname: originHostname,
- port: Number(originPort),
- });
- try {
- await Promise.all([copy(conn, origin), copy(origin, conn)]);
- } catch (e) {
- if (
- !(e instanceof Deno.errors.BrokenPipe) &&
- !(e instanceof Deno.errors.ConnectionReset)
- ) {
- throw e;
- }
- }
- conn.close();
- origin.close();
-}
-
-console.log(`Proxy listening on http://${addr}/`);
-for await (const conn of listener) {
- handle(conn);
-}
diff --git a/cli/bench/http.rs b/cli/bench/http.rs
index 585867892..9394f381b 100644
--- a/cli/bench/http.rs
+++ b/cli/bench/http.rs
@@ -31,12 +31,6 @@ pub(crate) fn benchmark(
// res.insert("deno_udp".to_string(), deno_udp(deno_exe)?);
res.insert("deno_http".to_string(), deno_http(deno_exe)?);
res.insert("deno_http_native".to_string(), deno_http_native(deno_exe)?);
- // TODO(ry) deno_proxy disabled to make fetch() standards compliant.
- // res.insert("deno_proxy".to_string(), deno_http_proxy(deno_exe) hyper_hello_exe))
- res.insert(
- "deno_proxy_tcp".to_string(),
- deno_tcp_proxy(deno_exe, hyper_hello_exe)?,
- );
// "core_http_json_ops" previously had a "bin op" counterpart called "core_http_bin_ops",
// which was previously also called "deno_core_http_bench", "deno_core_single"
res.insert(
@@ -45,11 +39,6 @@ pub(crate) fn benchmark(
);
// "node_http" was once called "node"
res.insert("node_http".to_string(), node_http()?);
- res.insert("node_proxy".to_string(), node_http_proxy(hyper_hello_exe)?);
- res.insert(
- "node_proxy_tcp".to_string(),
- node_tcp_proxy(hyper_hello_exe)?,
- );
res.insert("node_tcp".to_string(), node_tcp()?);
res.insert("hyper".to_string(), hyper_http(hyper_hello_exe)?);
@@ -150,31 +139,6 @@ fn deno_tcp(deno_exe: &str) -> Result<HttpBenchmarkResult> {
)
}
-fn deno_tcp_proxy(
- deno_exe: &str,
- hyper_exe: &str,
-) -> Result<HttpBenchmarkResult> {
- let port = get_port();
- let origin_port = get_port();
-
- println!("http_proxy_benchmark testing DENO using net/tcp.");
- run(
- &[
- deno_exe,
- "run",
- "--allow-net",
- "--reload",
- "--unstable",
- "cli/bench/deno_tcp_proxy.ts",
- &server_addr(port),
- &server_addr(origin_port),
- ],
- port,
- None,
- Some(&[hyper_exe, &origin_port.to_string()]),
- )
-}
-
fn deno_http(deno_exe: &str) -> Result<HttpBenchmarkResult> {
let port = get_port();
println!("http_benchmark testing DENO using net/http.");
@@ -212,32 +176,6 @@ fn deno_http_native(deno_exe: &str) -> Result<HttpBenchmarkResult> {
)
}
-#[allow(dead_code)]
-fn deno_http_proxy(
- deno_exe: &str,
- hyper_exe: &str,
-) -> Result<HttpBenchmarkResult> {
- let port = get_port();
- let origin_port = get_port();
-
- println!("http_proxy_benchmark testing DENO using net/http.");
- run(
- &[
- deno_exe,
- "run",
- "--allow-net",
- "--reload",
- "--unstable",
- "cli/bench/deno_http_proxy.ts",
- &server_addr(port),
- &server_addr(origin_port),
- ],
- port,
- None,
- Some(&[hyper_exe, &origin_port.to_string()]),
- )
-}
-
fn core_http_json_ops(exe: &str) -> Result<HttpBenchmarkResult> {
println!("http_benchmark testing CORE http_bench_json_ops");
run(&[exe], 4544, None, None)
@@ -254,44 +192,6 @@ fn node_http() -> Result<HttpBenchmarkResult> {
)
}
-fn node_http_proxy(hyper_exe: &str) -> Result<HttpBenchmarkResult> {
- let port = get_port();
- let origin_port = get_port();
- let origin_port = origin_port.to_string();
-
- println!("http_proxy_benchmark testing NODE.");
- run(
- &[
- "node",
- "cli/bench/node_http_proxy.js",
- &port.to_string(),
- &origin_port,
- ],
- port,
- None,
- Some(&[hyper_exe, &origin_port]),
- )
-}
-
-fn node_tcp_proxy(exe: &str) -> Result<HttpBenchmarkResult> {
- let port = get_port();
- let origin_port = get_port();
- let origin_port = origin_port.to_string();
-
- println!("http_proxy_benchmark testing NODE tcp.");
- run(
- &[
- "node",
- "cli/bench/node_tcp_proxy.js",
- &port.to_string(),
- &origin_port,
- ],
- port,
- None,
- Some(&[exe, &origin_port]),
- )
-}
-
fn node_tcp() -> Result<HttpBenchmarkResult> {
let port = get_port();
println!("http_benchmark testing node_tcp.js");
diff --git a/cli/bench/main.rs b/cli/bench/main.rs
index 8078259d9..67034ce63 100644
--- a/cli/bench/main.rs
+++ b/cli/bench/main.rs
@@ -16,7 +16,6 @@ use std::time::SystemTime;
mod http;
mod lsp;
-mod throughput;
fn read_json(filename: &str) -> Result<Value> {
let f = fs::File::open(filename)?;
@@ -326,17 +325,6 @@ fn bundle_benchmark(deno_exe: &Path) -> Result<HashMap<String, u64>> {
Ok(sizes)
}
-fn run_throughput(deno_exe: &Path) -> Result<HashMap<String, f64>> {
- let mut m = HashMap::<String, f64>::new();
-
- m.insert("100M_tcp".to_string(), throughput::tcp(deno_exe, 100)?);
- m.insert("100M_cat".to_string(), throughput::cat(deno_exe, 100));
- m.insert("10M_tcp".to_string(), throughput::tcp(deno_exe, 10)?);
- m.insert("10M_cat".to_string(), throughput::cat(deno_exe, 10));
-
- Ok(m)
-}
-
fn run_http(target_dir: &Path, new_data: &mut BenchResult) -> Result<()> {
let stats = http::benchmark(target_dir)?;
@@ -452,7 +440,6 @@ struct BenchResult {
req_per_sec: HashMap<String, u64>,
syscall_count: HashMap<String, u64>,
thread_count: HashMap<String, u64>,
- throughput: HashMap<String, f64>,
}
/*
@@ -495,10 +482,7 @@ fn main() -> Result<()> {
..Default::default()
};
- // Cannot run throughput benchmark on windows because they don't have nc or
- // pipe.
if cfg!(not(target_os = "windows")) {
- new_data.throughput = run_throughput(&deno_exe)?;
run_http(&target_dir, &mut new_data)?;
}
diff --git a/cli/bench/node_http_proxy.js b/cli/bench/node_http_proxy.js
deleted file mode 100644
index f97e3d5a8..000000000
--- a/cli/bench/node_http_proxy.js
+++ /dev/null
@@ -1,22 +0,0 @@
-// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
-const http = require("http");
-const port = process.argv[2] || "4544";
-const originPort = process.argv[3] || "4545";
-console.log("port", port);
-http
- .Server((req, res) => {
- const options = {
- port: originPort,
- path: req.url,
- method: req.method,
- headers: req.headers,
- };
-
- const proxy = http.request(options, (proxyRes) => {
- res.writeHead(proxyRes.statusCode, proxyRes.headers);
- proxyRes.pipe(res, { end: true });
- });
-
- req.pipe(proxy, { end: true });
- })
- .listen(port);
diff --git a/cli/bench/throughput.rs b/cli/bench/throughput.rs
deleted file mode 100644
index 0420889ef..000000000
--- a/cli/bench/throughput.rs
+++ /dev/null
@@ -1,63 +0,0 @@
-// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
-
-use super::Result;
-use std::{
- path::Path,
- process::Command,
- time::{Duration, Instant},
-};
-
-const MB: usize = 1024 * 1024;
-const SERVER_ADDR: &str = "0.0.0.0:4544";
-const CLIENT_ADDR: &str = "127.0.0.1 4544";
-
-pub(crate) fn cat(deno_exe: &Path, megs: usize) -> f64 {
- let size = megs * MB;
- let shell_cmd = format!(
- "{} run --allow-read cli/tests/testdata/cat.ts /dev/zero | head -c {}",
- deno_exe.to_str().unwrap(),
- size
- );
- println!("{}", shell_cmd);
- let cmd = &["sh", "-c", &shell_cmd];
-
- let start = Instant::now();
- let _ = test_util::run_collect(cmd, None, None, None, true);
- let end = Instant::now();
-
- (end - start).as_secs_f64()
-}
-
-pub(crate) fn tcp(deno_exe: &Path, megs: usize) -> Result<f64> {
- let size = megs * MB;
-
- // The GNU flavor of `nc` requires the `-N` flag to shutdown the network socket after EOF on stdin
- let nc_command = if cfg!(target_os = "linux") {
- "nc -N"
- } else {
- "nc"
- };
-
- let shell_cmd = format!(
- "head -c {} /dev/zero | {} {}",
- size, nc_command, CLIENT_ADDR
- );
- println!("{}", shell_cmd);
- let cmd = &["sh", "-c", &shell_cmd];
-
- // Run deno echo server in the background.
- let mut echo_server = Command::new(deno_exe.to_str().unwrap())
- .args(&["run", "--allow-net", "echo_server.ts", SERVER_ADDR])
- .current_dir(test_util::testdata_path())
- .spawn()?;
-
- std::thread::sleep(Duration::from_secs(5)); // wait for deno to wake up. TODO racy.
-
- let start = Instant::now();
- let _ = test_util::run_collect(cmd, None, None, None, true);
- let end = Instant::now();
-
- echo_server.kill()?;
-
- Ok((end - start).as_secs_f64())
-}