all repos — homestead @ 249bf8c7f676360f0d304d6a7dde701ecb96fcd7

Code for my website

Add startup performance metric

Alan Pearce
commit

249bf8c7f676360f0d304d6a7dde701ecb96fcd7

parent

2d15818c99b123aa6548bdd647d94cd2615680cc

1 file changed, 11 insertions(+), 0 deletions(-)

jump to
M src/index.tssrc/index.ts
@@ -1,3 +1,7 @@
+import { performance } from "node:perf_hooks"; + +performance.mark("startup-begin"); + import log from "loglevel"; import { server, metricsServer } from "./app";
@@ -23,3 +27,10 @@ metricsServed.stop();
served.stop(); process.exit(0); }); + +performance.mark("startup-end"); + +performance.measure("startup", "startup-begin", "startup-end"); +for (const entry of performance.getEntriesByName("startup")) { + log.info(`Startup took ${entry.duration} ms`); +}