Measuring Node.js Function Performance - 08-23-21

How fast is that new function?

 import { xx } from 'xx';
+import { performance } from 'perf_hooks';
@@ -160,7 +161,10 @@ const userSessionMiddleware = async (req: XRequest, res: ExpressResponse, ne
+        var t0 = performance.now();
         req.isBot = headersIndicateBot(req.headers);
+        var t1 = performance.now();
+        console.log('Took', (t1 - t0).toFixed(4), 'milliseconds to calculate is bot');

source: https://www.sitepoint.com/measuring-javascript-functions-performance/

\- [ js, node-js ]