Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Tuple vs Object vs Class V3
(version: 1)
Comparing performance of:
Array vs Object vs Class
Created:
one year ago
by:
Registered User
Jump to the latest result
Script Preparation code:
const N = 1000000; class Tuple { first; second; constructor(first, second) { this.first = first; this.second = second; } } function createArrayTuple(first, second) { return [first, second]; } function createObjectTuple(first, second) { return { first, second }; }
Tests:
Array
const xs = []; for (let i = 0; i < N; i++) { xs.push(createArrayTuple(i, 0)); }
Object
const xs = []; for (let i = 0; i < N; i++) { xs.push(createObjectTuple(i, 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:
one year ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36
Browser/OS:
Chrome 135 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Array
10.7 Ops/sec
Object
17.6 Ops/sec
Class
18.0 Ops/sec
Related benchmarks:
creation
object functions vs if statements 2
object functions vs if statements 3
Constructor vs object literal 2
Class instance method lookup vs function-created object method lookup (fork)
objct1 vs function1
class vs object vs function
{} vs Map with set
Tuple vs Object vs Class
Comments
Confirm delete:
Do you really want to delete benchmark?