Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
literal, literal spread, vs reuse
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36
Browser:
Chrome 126
Operating system:
Linux
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
literal spread
1830.0 Ops/sec
reuse
5338.9 Ops/sec
literal
3145.1 Ops/sec
Script Preparation code:
arr = []; for (let i = 0; i < 10000; i++) { arr.push({ a: Math.random(), b: Math.random(), c: Math.random() }) } total = 0;
Tests:
literal spread
const k = Math.random(); total += arr.map((obj) => { return { ...obj, d: obj.a + obj.b + k, }; }).reduce((total, obj) => { return total + obj.d / obj.c; }, 0);
reuse
const k = Math.random(); const r = { a: 0, b: 0, c: 0, d: 0, }; total += arr.map((obj) => { r.a = obj.a; r.b = obj.b; r.c = obj.c; r.d = obj.a + obj.b + k; return r; }).reduce((total, obj) => { return total + obj.d / obj.c; }, 0);
literal
const k = Math.random(); total += arr.map((obj) => { return { a: obj.a, b: obj.b, c: obj.c, d: obj.a + obj.b + k, }; }).reduce((total, obj) => { return total + obj.d / obj.c; }, 0);