Test() Vs Exec()
A small test to analyse the performance of two similar but different functions.
The first Test():
Executes the search for a match between a regular expression and a specified string. Returns true or false.
The second Exec()
Used to retrieve the matches when matching a string against a regular expression. Returns an array with the matches or null if there are none.
Comparing performance of: RegEx.test vs String.match
Memory measurements supported only in Chrome.
For precise memory measurements Chrome must be launched with --enable-precise-memory-info flag.
More information: Monitoring JavaScript Memory
Test case name
Result
RegEx.test
String.match
Fastest:N/A
Slowest:N/A
Latest run results:
Run details: (Test run date:
one year ago)
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36