--- title: "measuring node.js function performance" date: 2021-08-23T10:42:01+02:00 draft: false snippet_types: - js - node-js --- How fast is that new function? ```diff 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/