UNPKG

iso-bench

Version:

Small benchmark library focused in avoiding optimization/deoptimization pollution between tests by isolating them.

13 lines (12 loc) 401 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getDiff = getDiff; const perf_hooks_1 = require("perf_hooks"); function getDiff(cycles, callback, setup) { const setupData = setup && setup(); const startTS = perf_hooks_1.performance.now(); while (cycles-- > 0) { callback(setupData); } return perf_hooks_1.performance.now() - startTS; }