Last active
August 13, 2018 20:37
-
-
Save thlorenz/245dc6a701b226925a89ad699a78f896 to your computer and use it in GitHub Desktop.
Provide benchmark.js interface to just run functions meant to be benchmarked, i.e. to collect deoptimization info
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict' | |
const deferred = { | |
resolve: function dontCare() {} | |
} | |
class DeoptMark { | |
constructor({ ITER = 1E3 } = {}) { | |
this._ITER = ITER | |
this._fns = [] | |
} | |
add(name, fn, opts = {}) { | |
this._fns.push({ name, fn, opts }) | |
} | |
run() { | |
for (const { name, fn, opts } of this._fns) { | |
console.log(`Running ${name}`) | |
const ctx = {} | |
if (typeof opts.onStart === 'function') { | |
opts.onStart.call(ctx) | |
} | |
for (var i = 0; i < this._ITER; i++) { | |
fn.call(ctx, deferred) | |
} | |
} | |
} | |
} | |
const init = require(process.argv[2]) | |
const suite = new DeoptMark() | |
suite.cacheSizes = [16 ** 2, 16 ** 3, 16 ** 4] | |
init(suite) | |
suite.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment