Skip to content

Instantly share code, notes, and snippets.

@hyzhak
Created November 9, 2018 09:18
Show Gist options
  • Save hyzhak/6b4bfcf29b9172d421496183b32e482e to your computer and use it in GitHub Desktop.
Save hyzhak/6b4bfcf29b9172d421496183b32e482e to your computer and use it in GitHub Desktop.
short but useful function to measure performance of function in node.js
function perf(fn) { console.time('x'); fn(); console.timeEnd('x');}
@hyzhak
Copy link
Author

hyzhak commented Nov 9, 2018

usage:

const I = require('immutable');
s1 = I.Set(I.Range(1, 1e5).map(_ => Math.floor(1e5 * Math.random())));
s2 = I.Set(I.Range(1, 1e5).map(_ => Math.floor(1e5 * Math.random())));
perf(() => s1.union(s2));

result:

x: 62.706ms

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment