Skip to content

Instantly share code, notes, and snippets.

@te-online
Created October 1, 2018 14:48
Show Gist options
  • Save te-online/83cee84d40492ca1f64cda50b6bd93c3 to your computer and use it in GitHub Desktop.
Save te-online/83cee84d40492ca1f64cda50b6bd93c3 to your computer and use it in GitHub Desktop.
Node Performance measurement for laymen
const start = now();
// some task goes here
const end = now();
const time = (end-start).toFixed(4);
const currentList = process.env.PERFLIST;
const list = (currentList) ? JSON.parse(currentList) : [];
list.push(time);
process.env.PERFLIST = JSON.stringify(list);
list.sort();
console.log("current median:", list[Math.ceil(list.length / 2)], "with n:", list.length);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment