Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
variadics vs arrays
(version: 1)
testing wheter variadic params in functions are faster or slower than simply passing arrays as arguments
Comparing performance of:
variadic vs array
Created:
one year ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<!--your preparation HTML code goes here-->
Script Preparation code:
/*your preparation JavaScript code goes here To execute async code during the script preparation, wrap it as function globalMeasureThatScriptPrepareFunction, example:*/ async function globalMeasureThatScriptPrepareFunction() { // This function is optional, feel free to remove it. // await someThing(); }
Tests:
variadic
function test(...args) { let finalRep = ''; for(const item of args) { finalRep = item.toString(); } return finalRep; } const frep = test('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y','z');
array
function test(args) { let finalRep = ''; for(const item of args) { finalRep = item.toString(); } return finalRep; } const frep = test(['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y','z']);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
variadic
array
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
2 months ago
)
User agent:
Mozilla/5.0 (X11; Linux x86_64; rv:147.0) Gecko/20100101 Firefox/147.0
Browser/OS:
Firefox 147 on Linux
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
variadic
7255743.5 Ops/sec
array
6704257.5 Ops/sec
Related benchmarks:
Rest vs. Arguments to Array
await delay vs setTimeout
await delay vs setTimeout
await delay vs setTimeout
function vs const
converting arguments to Array
function vs class vs proto
Arguments to Array - by Jeeeyul
reate array by lenght
Comments
Confirm delete:
Do you really want to delete benchmark?