I know this is tagged front-end but if anyone comes across this looking for a node.js solution (like me), you need to first require performance from the perf_hooks module (available in node 8.5+).
const {performance} = require('perf_hooks');
const t0 = performance.now();
...