Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
compose versus array
(version: 1)
Comparing performance of:
array vs compose
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) + ")" return new Function ("x", "return " + body + ";"); } const compose = (f, g) => x => g(f(x)); const funs = [generateFunction ()]; let fun = funs[0]; console.log ("i", 0, fun); for (let i = 1 ; i < 20 ; i++) { const nfun = generateFunction (); console.log ("i", i, nfun); funs.push (nfun); fun = compose (nfun, fun); }
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 = fun (result);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
array
compose
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
8821102.0 Ops/sec
compose
5659973.5 Ops/sec
Related benchmarks:
each-or-plain
Object vs Map
Object entries, values, keys, and Array.from
get with insert : Array vs Map 3
entries vs for vs foreach vs some vs every length
+ '' vs .toString() v5 rand
Function vs dynamic function vs strict dynamic function
JavaScript String Starts/Ends With String Comparisons - Playground
Mappers
Comments
Confirm delete:
Do you really want to delete benchmark?