summaryrefslogtreecommitdiff
path: root/cli/bench
diff options
context:
space:
mode:
Diffstat (limited to 'cli/bench')
-rw-r--r--cli/bench/deno_http_native.js17
-rw-r--r--cli/bench/http.rs20
2 files changed, 37 insertions, 0 deletions
diff --git a/cli/bench/deno_http_native.js b/cli/bench/deno_http_native.js
new file mode 100644
index 000000000..fa779be21
--- /dev/null
+++ b/cli/bench/deno_http_native.js
@@ -0,0 +1,17 @@
+// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
+
+const addr = Deno.args[0] || "127.0.0.1:4500";
+const [hostname, port] = addr.split(":");
+const listener = Deno.listen({ hostname, port: Number(port) });
+console.log("Server listening on", addr);
+
+const body = Deno.core.encode("Hello World");
+
+for await (const conn of listener) {
+ (async () => {
+ const requests = Deno.startHttp(conn);
+ for await (const { respondWith } of requests) {
+ respondWith(new Response(body));
+ }
+ })();
+}
diff --git a/cli/bench/http.rs b/cli/bench/http.rs
index 952f3f19b..690e26cf4 100644
--- a/cli/bench/http.rs
+++ b/cli/bench/http.rs
@@ -33,6 +33,7 @@ pub(crate) fn benchmark(
res.insert("deno_tcp".to_string(), deno_tcp(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_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(
@@ -200,6 +201,25 @@ fn deno_http(deno_exe: &str) -> Result<HttpBenchmarkResult> {
)
}
+fn deno_http_native(deno_exe: &str) -> Result<HttpBenchmarkResult> {
+ let port = get_port();
+ println!("http_benchmark testing DENO using native bindings.");
+ run(
+ &[
+ deno_exe,
+ "run",
+ "--allow-net",
+ "--reload",
+ "--unstable",
+ "cli/bench/deno_http_native.js",
+ &server_addr(port),
+ ],
+ port,
+ None,
+ None,
+ )
+}
+
#[allow(dead_code)]
fn deno_http_proxy(
deno_exe: &str,