Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
rest parameters vs arguments
(version: 0)
Comparing performance of:
arguments vs rest parameter
Created:
5 years ago
by:
Guest
Jump to the latest result
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)); } }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
arguments
rest parameter
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
7 months ago
)
User agent:
Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Mobile Safari/537.36
Browser/OS:
Chrome Mobile 140 on Android
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
arguments
2442.0 Ops/sec
rest parameter
3346.8 Ops/sec
Related benchmarks:
rest parameters vs arguments1
rest parameters vs arguments2
rest parameters vs arguments 2
rest parameters vs arguments 3
Comments
Confirm delete:
Do you really want to delete benchmark?