leafiy
5/18/2018 - 6:53 PM

timeTaken #js #date

测量执行函数所用的时间。

const timeTaken = callback => {
console.time('timeTaken');  const r = callback();
console.timeEnd('timeTaken');  return r;
};
// timeTaken(() => Math.pow(2, 10)) -> 1024
// (logged): timeTaken: 0.02099609375ms