Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
Feature Requests
FAQ
Register
Log In
Set<string> vs Array<string> lookup (existing set)
(version: 1)
Benchmark.js
Comparing performance of: Array Lookup vs Set Lookup when the values are string.
Comparing performance of:
Array Lookup vs Set Lookup
Created:
15 days ago
by:
Registered User
Go to the latest result
HTML Preparation code:
<!--your preparation HTML code goes here-->
Script Preparation code:
const arr = [ 'text', 'search', 'tel', 'url', 'password' ]; const set = new Set(arr);
Tests:
Array Lookup
// exercise all out-of-order using unique string instances (avoid arr[0] ect which would compare by reference) arr.includes('url') arr.includes('text') arr.includes('tel') arr.includes('password') arr.includes('search')
Set Lookup
// exercise all out-of-order using unique string instances (avoid arr[0] ect which would compare by reference) set.has('url') set.has('text') set.has('tel') set.has('password') set.has('search')
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Array Lookup
Set Lookup
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
15 days ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/151.0.0.0 Safari/537.36
Browser/OS:
Chrome 151 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Set Lookup
1096.5M/s
Array Lookup
67.3M/s
View exact numbers
Test name
Executions per second
✓
Set Lookup
1,096,521,216 Ops/sec
Array Lookup
67,340,424 Ops/sec
Related benchmarks
Array.includes vs String compare v2
String in Array: Set vs Object lookup vs IndexOf vs includes vs findIndex vs find v2
find vs lookup
Array.includes vs Logic or
Comments
Confirm delete:
Do you really want to delete benchmark?