massive performance fixes

This commit is contained in:
2023-05-12 10:16:26 +02:00
parent 42ae41ba87
commit 60b819b9a4
2 changed files with 43 additions and 38 deletions

View File

@@ -5,12 +5,9 @@ import { HTTPServer } from "../mod.ts";
const httpServer = new HTTPServer();
httpServer.middleware(async (req, done) => {
const perStart = performance.now();
console.log(`${req.method} - ${req.ip()} - ${req.path}`);
await done();
const pt = performance.now() - perStart;
const hrArray: number[] = [0, Math.trunc(pt * 1000000)];
console.log(`Processed in ${prettyTime(hrArray)}`);
console.log(`${req.method} - ${req.remoteIpAddr} - ${req.path}`);
const processTime = await done();
console.log(`Processed in ${prettyTime(processTime)}`);
});
httpServer.error((req, _rep) => {