Skip to content

Instantly share code, notes, and snippets.

@mholtzhausen
Last active January 22, 2020 15:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mholtzhausen/a267c14fd0a73e1f9aa95b085d2134c3 to your computer and use it in GitHub Desktop.
Save mholtzhausen/a267c14fd0a73e1f9aa95b085d2134c3 to your computer and use it in GitHub Desktop.
import { serve } from "https://deno.land/std@v0.30.0/http/server.ts";
const s = serve({ port: 8000 });
console.log("http://localhost:8000/");
let c=0
let st=null
for await (const req of s) {
if(st===null)st=Date.now()
let sd=(Date.now()-st)/1000
let rps=(c+1)/sd
req.respond({ body: `Hello World\nRequests Handled:${c++}\nSeconds:${sd}\nRPS: ${rps}` });
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment