Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Option[Double]: box vs unbox
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36
Browser:
Chrome 129
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
box
63223.8 Ops/sec
unbox
14530.7 Ops/sec
Script Preparation code:
function None() { } None.prototype.tag = 0; const none = new None(); function Some(payload) { this.payload = payload; } Some.prototype.tag = 1; var box = []; var unbox = []; for (let i = 0; i < 1000; i++) { box.push(i % 2 == 0 ? none : new Some(i * Math.PI)); unbox.push(i % 2 == 0 ? undefined : i * Math.PI); } function square(i) { return i * i }
Tests:
box
for (let i of box) { if (i.tag === 1) { square(i.payload) } }
unbox
for (let i of unbox) { if (i !== undefined) { square(i) } }