Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
compose versus array versus merged versus meged use strict
(version: 1)
Comparing performance of:
array vs compose vs merge vs merge use strict
Created:
7 months ago
by:
Guest
Jump to the latest result
Script Preparation code:
function generateFunction () { let body = "x"; body += (Math.random () > 0.5) ? "*" : "+"; body += Math.floor (1 + Math.random () * 100); if (Math.random () > 0.75) body = "Math.min (" + body + "," + Math.floor (1 + Math.random () * 100) + ")"; const parameters = ["x"]; const expression = "return " + body + ";" const fun = new Function ("x", expression); fun.expression = expression fun.parameters = parameters; return fun; } const compose = (f, g) => x => g(f(x)); const funs = [generateFunction ()]; let funComposed = funs[0]; let expression = funComposed.expression; const len = 20; for (let i = 1 ; i < len ; i++) { const nfun = generateFunction (); expression = nfun.expression.replace ("return ", "x = ") + expression; console.log ("i", i, nfun); funs.push (nfun); funComposed = compose (nfun, funComposed); } const funMerged = new Function ("x", expression); const funMergedUseStrict = new Function ("x", "'use strict';" + expression);
Tests:
array
let result = Math.floor (Math.random () * 100); for (let i = funs.length - 1 ; i >= 0 ; i--) result = funs[i] (result);
compose
let result = Math.floor (Math.random () * 100); result = funComposed (result);
merge
let result = Math.floor (Math.random () * 100); result = funMerged (result);
merge use strict
let result = Math.floor (Math.random () * 100); result = funMergedUseStrict (result);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (4)
Previous results
Fork
Test case name
Result
array
compose
merge
merge use strict
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
7 months ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36
Browser/OS:
Chrome 140 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
array
8889621.0 Ops/sec
compose
5504024.5 Ops/sec
merge
61552516.0 Ops/sec
merge use strict
61545336.0 Ops/sec
Related benchmarks:
Object vs Map
asdfasdffdas
Object entries, values, keys, and Array.from
stringify & parse vs filter
entries vs for vs foreach vs some vs every length
JavaScript String Starts/Ends With String Comparisons - Playground
Function vs () =>
compose versus array
compose versus array versus merged
Comments
Confirm delete:
Do you really want to delete benchmark?