Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Object vs Turple 7
创建、访问大量 嵌套的、包含随机数字、字符串和嵌套内容的 多态对象、元组
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/85.0.4173.0 Safari/537.36
Browser:
Chrome 85
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
Create Turple #1
5.0 Ops/sec
Create Object #1
4.8 Ops/sec
Create Turple #1 (mirror, diff order)
5.0 Ops/sec
Create Object #1 (mirror, diff order)
4.8 Ops/sec
Access Turples #1
4.0 Ops/sec
Access Objects #1
3.9 Ops/sec
Script Preparation code:
let times = 100000 let turples, objects
Tests:
Create Turple #1
let times = 100000 const a = [] for(let i = 0; i <= times; i++) { a.push([Math.sin(i), Math.cos(i), Math.tan(i), Math.sin(i+0.5), Math.cos(i+0.5), Math.tan(i+0.5), [(Math.random() + 1).toString(36), (Math.random() + 1).toString(36)], i > 0 ? a[i-1] : undefined ]) a.push([1, 2, 3, Symbol("test"), "1"]) } turples = a
Create Object #1
let times = 100000 const a = [] for(let i = 0; i <= times; i++) { a.push({key1: Math.sin(i), very_long_key2: Math.cos(i), 2: Math.tan(i), very_very_very_very_long_key4: Math.sin(i+0.5), key5: Math.cos(i+0.5), key6:Math.tan(i+0.5), nested: { x: (Math.random() + 1).toString(36), y: (Math.random() + 1).toString(36) }, ref: i > 0 ? a[i-1] : undefined }) a.push({key1: 1, very_long_key2: 2, 2: 3, very_very_very_very_long_key4: Symbol("test"), key5: "1"}) } objects = a
Create Turple #1 (mirror, diff order)
let times = 100000 const a = [] for(let i = 0; i <= times; i++) { a.push([Math.sin(i), Math.cos(i), Math.tan(i), Math.sin(i+0.5), Math.cos(i+0.5), Math.tan(i+0.5), [(Math.random() + 1).toString(36), (Math.random() + 1).toString(36)], i > 0 ? a[i-1] : undefined ]) a.push([1, 2, 3, Symbol("test"), "1"]) }
Create Object #1 (mirror, diff order)
let times = 100000 const a = [] for(let i = 0; i <= times; i++) { a.push({key1: Math.sin(i), very_long_key2: Math.cos(i), 2: Math.tan(i), very_very_very_very_long_key4: Math.sin(i+0.5), key5: Math.cos(i+0.5), key6:Math.tan(i+0.5), nested: { x: (Math.random() + 1).toString(36), y: (Math.random() + 1).toString(36) }, ref: i > 0 ? a[i-1] : undefined }) a.push({key1: 1, very_long_key2: 2, 2: 3, very_very_very_very_long_key4: Symbol("test"), key5: "1"}) }
Access Turples #1
for(let i = 1; i < turples.length; i++) { turples[i-1][0] = turples[i][1] turples[i-1][1] = turples[i][2] turples[i-1][2] = turples[i][3] turples[i-1][3] = turples[i][4] if(turples[i][6]) { let x = turples[i][6][0] turples[i][6][0] = turples[i][6][1] turples[i][6][1] = x } }
Access Objects #1
for(let i = 1; i < turples.length; i++) { objects[i-1].key1 = objects[i].very_long_key2 objects[i-1].very_long_key2 = objects[i][2] objects[i-1][2] = objects[i].very_very_very_very_long_key4 objects[i-1].very_very_very_very_long_key4 = objects[i].key5 if(objects[i].nested) { let x = objects[i].nested.x objects[i].nested.x = objects[i].nested.y objects[i].nested.y = x } }
Create Mixed #1
let times = 100000 const a = [] for(let i = 0; i <= times; i++) { a.push({0: Math.sin(i), 1: Math.cos(i), 2: Math.tan(i), 3: Math.sin(i+0.5), 4: Math.cos(i+0.5), 5:Math.tan(i+0.5), 6: [ (Math.random() + 1).toString(36), (Math.random() + 1).toString(36) ], ref: i > 0 ? a[i-1] : undefined }) a.push({0: 1, 1: 2, 2: 3, 3: Symbol("test"), key4: "1"}) }