Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Tuple vs Object vs Class
(version: 1)
Comparing performance of:
Array vs Object vs Class
Created:
one year ago
by:
Guest
Jump to the latest result
Script Preparation code:
const N = 1000000; class Tuple { first; second; constructor(first, second) { this.first = first; this.second = second; } }
Tests:
Array
const xs = []; for (let i = 0; i < N; i++) { xs.push([i, 0]); }
Object
const xs = []; for (let i = 0; i < N; i++) { xs.push({ first: i, second: 0 }); }
Class
const xs = []; for (let i = 0; i < N; i++) { xs.push(new Tuple(i, 0)); }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
Array
Object
Class
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
3 months ago
)
User agent:
Mozilla/5.0 (X11; Linux x86_64; rv:146.0) Gecko/20100101 Firefox/146.0
Browser/OS:
Firefox 146 on Linux
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Array
58.2 Ops/sec
Object
73.1 Ops/sec
Class
23.5 Ops/sec
Related benchmarks:
Array.reduce
creation
Constructor vs object literal 2
Object destructuring performance
for loop length vs length+1 vs less-equal
Object vs Class performance
{} vs Map with set
{} vs Map with set and GET value
Tuple vs Object vs Class V3
Comments
Confirm delete:
Do you really want to delete benchmark?