all repos — website @ 8de5eac6f52beba26d3ce6b5406dcf4ac35da641

My website

Add startup performance metric
Alan Pearce alan@alanpearce.eu
Wed, 10 Apr 2024 10:31:55 +0200
commit

8de5eac6f52beba26d3ce6b5406dcf4ac35da641

parent

458893bd57da4164900e568af801481d68fbb13f

1 files 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`);
+}