add the old snippet md files
This commit is contained in:
parent
fc0dd204c7
commit
bcf8313a4b
110 changed files with 3048 additions and 0 deletions
24
old_snippets/measuring-node-js-fn-performance.md
Normal file
24
old_snippets/measuring-node-js-fn-performance.md
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
---
|
||||
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/
|
||||
Loading…
Add table
Add a link
Reference in a new issue