Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
js custom yield vs base ma
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36
Browser:
Chrome 131
Operating system:
Linux
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
yield
16.8 Ops/sec
base
17.9 Ops/sec
Tests:
yield
const arr = []; for (let i = 0; i < 100000; i++) { const obj = {}; for (let j = 0; j < 10; j++) { obj[`prop_${j}`] = j; } arr.push(obj); } const where = function*(isMatch) { for (let item of this) { if (isMatch(item)) { yield item; } } }; const select = function*(fn) { for (let item of this) { yield fn(item); } }; const toArray = function() { return Array.from(this); }; const Generator = Object.getPrototypeOf(function*() {}); Generator.prototype.where = where; Array.prototype.where = where; Generator.prototype.select = select; Array.prototype.select = select; Generator.prototype.toArray = toArray; Array.prototype.toArray = toArray; arr.select((obj) => obj.prop_3) .where((num) => num > 5) .toArray();
base
const arr = []; for (let i = 0; i < 100000; i++) { const obj = {}; for (let j = 0; j < 10; j++) { obj[`prop_${j}`] = j; } arr.push(obj); } const where = function*(isMatch) { for (let item of this) { if (isMatch(item)) { yield item; } } }; const select = function*(fn) { for (let item of this) { yield fn(item); } }; const toArray = function() { return Array.from(this); }; const Generator = Object.getPrototypeOf(function*() {}); Generator.prototype.where = where; Array.prototype.where = where; Generator.prototype.select = select; Array.prototype.select = select; Generator.prototype.toArray = toArray; Array.prototype.toArray = toArray; arr.map((obj) => obj.prop_3).filter((num) => num > 5);