Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Inline JS vs Single Function vs Function Composition
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/122.0.0.0 Safari/537.36 Edg/122.0.0.0
Browser:
Chrome 122
Operating system:
Windows
Device Platform:
Desktop
Date tested:
2 years ago
Test name
Executions per second
Inline JS
15589763.0 Ops/sec
Single Function
4521183.0 Ops/sec
Function Composition
4161920.8 Ops/sec
Script Preparation code:
// 1. Inline code will be directly in test case // 2. Single Functions globalThis.singleFunction = () => { const arr1 = [1, -12, 7]; const arr2 = arr1.filter(v => v > 0); return [...arr1, ...arr2]; }; // 3. Function Composition const makeArr = (a, b, c) => [a, b, c]; const filterPositive = arr => arr.filter(v => v > 0); const mergeArrays = (a, b) => [...a, ...b]; globalThis.composition = () => { const arr1 = makeArr(1, -12, 7); const arr2 = filterPositive(arr1); return mergeArrays(arr1, arr2); };
Tests:
Inline JS
const arr1 = [1, -12, 7]; const arr2 = arr1.filter(v => v > 0); const result = [...arr1, ...arr2];
Single Function
const result = singleFunction();
Function Composition
const result = composition();