Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
rest parameters vs arguments
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36 Edg/124.0.0.0
Browser:
Chrome 124
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
arguments
7125.4 Ops/sec
rest parameter
8583.4 Ops/sec
Script Preparation code:
function h1(tag, props) { props = Object.assign({}, props); let length = arguments.length; if (length > 3) { const children = []; while (length-- > 2) { children[length - 2] = arguments[length]; } props.children = children; } else if (length === 3) { props.children = arguments[2]; } return { tag, props }; } function h2(tag, props, ...children) { props = Object.assign({}, props); if (children.length > 1) { props.children = children; } else if (children.length === 1) { props.children = children[0]; } return { tag, props }; }
Tests:
arguments
const els = []; for (let i = 0; i < 1000; i++) { if (i % 3 === 0) { els.push(h1('div', {class: 'foo'}, i, i + 1, i + 2)); } else { els.push(h1('div', {class: 'foo'}, i)); } }
rest parameter
const els = []; for (let i = 0; i < 1000; i++) { if (i % 3 === 0) { els.push(h2('div', {class: 'foo'}, i, i + 1, i + 2)); } else { els.push(h2('div', {class: 'foo'}, i)); } }