Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
traverse Array vs Set
(version: 1)
array与set遍历性能对比
Comparing performance of:
array vs set
Created:
2 months ago
by:
Registered User
Jump to the latest result
HTML Preparation code:
<!--your preparation HTML code goes here-->
Script Preparation code:
let arr = []; let set = new Set(); function createArray() { for(let i=0; i< 1e4; i++) { arr.push(Math.random()); set.add(Math.random()); } } function operator(num){ return num++ } function traverseSet() { set.forEach(operator) } function traverseArray() { for(let i=0; i< arr.length; i++) { operator(arr[i]) } }
Tests:
array
traverseArray()
set
traverseSet()
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
array
set
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
2 months ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36 Edg/144.0.0.0
Browser/OS:
Chrome 144 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
array
134419520.0 Ops/sec
set
116767360.0 Ops/sec
Related benchmarks:
isArray vs instanceof vs Symbol.iterator
Array type test comparison
contains misses: Map vs Set vs Array vs Symbol vs UID
Array.find vs. Map.get (small scale)
Find last element of an array
Find last element of an array no empty array
montest
my testtestets
flat typed array vs 2d typed array
Comments
Confirm delete:
Do you really want to delete benchmark?