1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-25 15:29:32 -05:00

Remove some unused benchmarks (#12315)

This commit is contained in:
Ryan Dahl 2021-10-05 22:27:44 -04:00 committed by GitHub
parent 2b39e74477
commit 10c415eaaa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 0 additions and 256 deletions

View file

@ -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);
}

View file

@ -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);
}

View file

@ -31,12 +31,6 @@ pub(crate) fn benchmark(
// res.insert("deno_udp".to_string(), deno_udp(deno_exe)?); // res.insert("deno_udp".to_string(), deno_udp(deno_exe)?);
res.insert("deno_http".to_string(), deno_http(deno_exe)?); res.insert("deno_http".to_string(), deno_http(deno_exe)?);
res.insert("deno_http_native".to_string(), deno_http_native(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", // "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" // which was previously also called "deno_core_http_bench", "deno_core_single"
res.insert( res.insert(
@ -45,11 +39,6 @@ pub(crate) fn benchmark(
); );
// "node_http" was once called "node" // "node_http" was once called "node"
res.insert("node_http".to_string(), node_http()?); 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("node_tcp".to_string(), node_tcp()?);
res.insert("hyper".to_string(), hyper_http(hyper_hello_exe)?); 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> { fn deno_http(deno_exe: &str) -> Result<HttpBenchmarkResult> {
let port = get_port(); let port = get_port();
println!("http_benchmark testing DENO using net/http."); 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> { fn core_http_json_ops(exe: &str) -> Result<HttpBenchmarkResult> {
println!("http_benchmark testing CORE http_bench_json_ops"); println!("http_benchmark testing CORE http_bench_json_ops");
run(&[exe], 4544, None, None) 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> { fn node_tcp() -> Result<HttpBenchmarkResult> {
let port = get_port(); let port = get_port();
println!("http_benchmark testing node_tcp.js"); println!("http_benchmark testing node_tcp.js");

View file

@ -16,7 +16,6 @@ use std::time::SystemTime;
mod http; mod http;
mod lsp; mod lsp;
mod throughput;
fn read_json(filename: &str) -> Result<Value> { fn read_json(filename: &str) -> Result<Value> {
let f = fs::File::open(filename)?; let f = fs::File::open(filename)?;
@ -326,17 +325,6 @@ fn bundle_benchmark(deno_exe: &Path) -> Result<HashMap<String, u64>> {
Ok(sizes) 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<()> { fn run_http(target_dir: &Path, new_data: &mut BenchResult) -> Result<()> {
let stats = http::benchmark(target_dir)?; let stats = http::benchmark(target_dir)?;
@ -452,7 +440,6 @@ struct BenchResult {
req_per_sec: HashMap<String, u64>, req_per_sec: HashMap<String, u64>,
syscall_count: HashMap<String, u64>, syscall_count: HashMap<String, u64>,
thread_count: HashMap<String, u64>, thread_count: HashMap<String, u64>,
throughput: HashMap<String, f64>,
} }
/* /*
@ -495,10 +482,7 @@ fn main() -> Result<()> {
..Default::default() ..Default::default()
}; };
// Cannot run throughput benchmark on windows because they don't have nc or
// pipe.
if cfg!(not(target_os = "windows")) { if cfg!(not(target_os = "windows")) {
new_data.throughput = run_throughput(&deno_exe)?;
run_http(&target_dir, &mut new_data)?; run_http(&target_dir, &mut new_data)?;
} }

View file

@ -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);

View file

@ -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())
}