Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
set has vs regex
(version: 1)
Comparing performance of:
set has vs regex vs in check vs hasOwnProperty
Created:
one year ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<!--your preparation HTML code goes here-->
Script Preparation code:
let str = `qwertyuiopasdfghjklzxcvbnm`.split('') let set = new Set(str) let regex = RegExp(str.join('|')) let obj = Object.fromEntries(str.map(o=>[str,str])) let hop = hasOwnProperty.bind(obj)
Tests:
set has
set.has('1') set.has('m')
regex
regex.test('1') regex.test('m')
in check
1 in obj 'm'in obj
hasOwnProperty
hop(obj, 1) hop(obj, 'm')
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (4)
Previous results
Fork
Test case name
Result
set has
regex
in check
hasOwnProperty
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
3 months ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36
Browser/OS:
Chrome 144 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
set has
192848624.0 Ops/sec
regex
47224812.0 Ops/sec
in check
233684432.0 Ops/sec
hasOwnProperty
7907017.0 Ops/sec
Related benchmarks:
WebApp Test
String compare VS regex
String.match 2
String.match 4
compare regex pattern
starts with vs regex
r includes vs regex
starts/endswith vs regex.test
capturing and non capturing regex
Comments
Confirm delete:
Do you really want to delete benchmark?