Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
test b@b regexp list
(version: 0)
Comparing performance of:
regexp of list vs list of regexps
Created:
2 years ago
by:
Guest
Jump to the latest result
Tests:
regexp of list
new RegExp("(^([^./]+\\.)*slack\\.com/)|(^([^./]+\\.)*microsoft\\.com/)|(^([^./]+\\.)*beamy\\.io/)").test("sub1.sub2.beamy.io/");
list of regexps
new RegExp("^([^./]+\\.)*slack\\.com/").test("sub1.sub2.beamy.io/"); new RegExp("^([^./]+\\.)*microsoft\\.com/").test("sub1.sub2.beamy.io/"); new RegExp("^([^./]+\\.)*beamy\\.io/").test("sub1.sub2.beamy.io/");
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
regexp of list
list of regexps
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
2 years ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36
Browser/OS:
Chrome 121 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
regexp of list
2884786.0 Ops/sec
list of regexps
1955119.6 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
I'll break down the benchmark test cases and explain what's being tested. **What is being tested?** The provided benchmark tests regular expression (RegExp) performance in JavaScript, specifically: 1. `regexp of list`: This test case uses a single RegExp object to match different strings against three patterns (`slack.com`, `microsoft.com`, and `beamy.io`). The test checks how many times the RegExp object can be executed in one second. 2. `list of regexps`: This test case creates multiple separate RegExp objects for each pattern (three in this case) and executes them individually in a loop. It then repeats the process of executing all three Regexp objects together. **Options compared** The two main options being compared are: 1. **Single RegExp object vs. Multiple separate RegExp objects**: The first test case uses a single RegExp object, while the second test case creates multiple separate RegExp objects for each pattern. 2. **Sequential execution vs. Combined execution**: In the `list of regexps` test case, the Regexp objects are executed individually in a loop (sequential), whereas in the `regexp of list` test case, all three Regexp objects are executed together. **Pros and Cons** **Single RegExp object:** Pros: * Less memory usage, as only one RegExp object is created. * Can be faster, since it's not creating multiple instances of the same function. Cons: * May lead to slower performance due to repeated recompilation of the RegExp object. * More difficult to maintain and debug, if the patterns change. **Multiple separate RegExp objects:** Pros: * Faster execution, as each Regexp object is only compiled once. * Easier maintenance and debugging, since each pattern can be modified independently. Cons: * More memory usage, due to multiple instances of the same function being created. * May lead to slower performance if the number of patterns increases. **Other considerations** In general, creating separate RegExp objects for different patterns can be beneficial when: * The patterns are complex or have many alternatives. * The patterns need to be modified independently. * Speed is a critical factor in your application. However, creating a single RegExp object with multiple patterns can be beneficial when: * The number of patterns is small (less than 10-15). * Memory usage is a concern. * Recompilation of the RegExp object is not necessary due to caching. **Library and special JS features** There are no libraries mentioned in the provided benchmark. However, it's worth noting that some JavaScript engines have built-in optimizations for Regexp performance, such as: * Caching: Some engines cache compiled Regexp objects to reduce recompilation time. * Just-In-Time (JIT) compilation: Engines like V8 (used by Chrome) can JIT compile Regexp patterns to generate machine code. **Test user special JS feature** There are no specific JavaScript features mentioned in the provided benchmark. However, it's worth noting that some benchmarks might test performance of specific features like: * `String.prototype.replace()` * `Array.prototype.indexOf()` * `Object.keys()` and friends In conclusion, this benchmark is testing the performance of regular expression execution in JavaScript, specifically comparing the use of a single RegExp object versus multiple separate Regexp objects. The results can provide insights into the optimal way to handle complex patterns and caching strategies for improved performance.
Related benchmarks:
regex vs length
Case insensitive string comparison 2
RegEx.test vs. String.includes larger
new RegExp test
startsWith vs test 3
Comments
Confirm delete:
Do you really want to delete benchmark?