benchmark.js 307 Bytes Raw Blame History Permalink 1 2 3 4 5 6 7 8 9 10 11 12 13 function benchmark(fn, ctx) { return function() { let t = new Date(); let result = fn.apply(ctx, arguments).then(r => { console.log('benchmark', fn.name, `[${ new Date() - t}]`); return r; }); return result; }; } module.exports = benchmark;