Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
compose versus array
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/140.0.0.0 Safari/537.36
Browser:
Chrome 140
Operating system:
Windows
Device Platform:
Desktop
Date tested:
7 months ago
Test name
Executions per second
array
8821102.0 Ops/sec
compose
5659973.5 Ops/sec
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);