1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-25 08:39:09 -05:00

Add http_bench.ts

Original: 82ceb596f3
This commit is contained in:
Ryan Dahl 2018-12-06 17:19:12 -05:00
parent c5871cb996
commit 16aedf68ea
2 changed files with 15 additions and 22 deletions

15
http_bench.ts Normal file
View file

@ -0,0 +1,15 @@
import * as deno from "deno";
import { serve } from "https://deno.land/x/net/http.ts";
const addr = deno.args[1] || "127.0.0.1:4500";
const server = serve(addr);
const body = new TextEncoder().encode("Hello World");
async function main(): Promise<void> {
for await (const request of server) {
await request.respond({ status: 200, body });
}
}
main();

View file

@ -1,22 +0,0 @@
import { serve } from "./http.ts";
//import { test } from "https://deno.land/x/testing/testing.ts";
const addr = "0.0.0.0:8000";
const s = serve(addr);
console.log(`listening on http://${addr}/`);
const body = new TextEncoder().encode("Hello World\n");
async function main() {
for await (const req of s) {
await req.respond({ status: 200, body });
}
}
main();
/*
test(function basic() {
console.log("ok");
});
*/