new Benchmark.Suite('closure') .add('non-closure', function() { return nonClosure(['hi', 'bye', 'yay']) }) .add('closure', function() { return closure(['hi', 'bye', 'yay']) }) .on('cycle', function(event) { console.log(String(event.target)) }) .on('complete', function() { console.log('Fastest is ' + this.filter('fastest').map('name')) }) .run({ async: false })
new Benchmark.Suite('last_string_index', { onStart: () => { str = Math.floor(Math.random() * 1000).toString(10) } }) .add('a', function() { return a.x === b.x }) .on('cycle', function(event) { console.log(String(event.target)) }) .on('complete', function() { console.log('Fastest is ' + this.filter('fastest').map('name')) }) .run({ async: false })
new Benchmark.Suite('is_array') .add('Array.isArray', function() { return Array.isArray([]) }) .add('constructor.prototype === Array.prototype', function() { return [].constructor.prototype === Array.prototype }) .add('instanceof Array', function() { return [] instanceof Array }) .on('cycle', function(event) { console.log(String(event.target)) }) .on('complete', function() { console.log('Fastest is ' + this.filter('fastest').map('name')) }) .run({ async: false })
new Benchmark.Suite() .add('Sqorn - args', function() { sq
new Benchmark.Suite() .add('sqorn complex', function() { sq
new Benchmark.Suite() .add('a', function() { return source.map(s => double(s)).join(', ')
new Benchmark.Suite('last_string_index', { onStart: () => { str = Math.floor(Math.random() * 1000).toString(10) } }) .add('a', function() { return str.endsWith('$') }) .add('b', function() { return str.slice(-1) === '$' }) .add('c', function() { return str[str.length - 1] === '$' }) .on('cycle', function(event) { console.log(String(event.target)) }) .on('complete', function() { console.log('Fastest is ' + this.filter('fastest').map('name')) }) .run({ async: false })
new Benchmark.Suite('last_string_index', {}) .add('{}}', function() { const a = {} const b = {} const c = {} const d = {} const e = {} }) .on('new Object()', function(event) { const a = new Object() const b = new Object() const c = new Object() const d = new Object() const e = new Object() }) .on('new fn', function(event) { }) .on('complete', function() { console.log('Fastest is ' + this.filter('fastest').map('name')) }) .run({ async: false })
new Benchmark.Suite('last_string_index', { onStart: () => { str = Math.floor(Math.random() * 1000).toString(10) } }) .add('obj', function() { const { x, y } = obj() return x + y }) .add('arr', function() { const [x, y] = arr() return x + y }) .add('robj', function() { const { x, y } = robj() return x + y }) .add('rarr', function() { const [x, y] = rarr() return x + y }) .on('cycle', function(event) { console.log(String(event.target)) }) .on('complete', function() { console.log('Fastest is ' + this.filter('fastest').map('name')) }) .run({ async: false })
const createSuite = () => new Benchmark.Suite() .on("cycle", event => { if (event.target.error) { event.target.error = { stack: event.target.error.stack }; } bb.add(event.target); }) .on("complete", () => { bb.log(); runNextTest(); })
function run (root) { const suite = Benchmark.Suite() suite.add('walk-sync', function () { walkSync(root) }).add('klaw-sync', function () { klawSync(root) }).on('error', function (er) { return er }).on('cycle', function (ev) { console.log(String(ev.target)) }).on('complete', function () { console.log('Fastest is ' + this.filter('fastest').map('name')) }).run() }