Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Recursive Iteration VS. Dynamic RegExp
(version: 1)
Comparing performance of:
Recursive Iteration vs Dynamic RegExp
Created:
4 years ago
by:
Registered User
Jump to the latest result
Script Preparation code:
var parentIds = (new Array(500_000)).map(i => `http://parent/${i}`); var activeParentIds = parentIds.filter((_, i) => i % 2 === 0); var pendingChildren = parentIds.reduce((acc, parentId) => ({ ...acc, [parentId + '|A']: true, [parentId + '|B']: false, [parentId + '|C']: true, }), {})
Tests:
Recursive Iteration
Object.entries(pendingChildren).some(([childKey, isPending]) => isPending && activeParentIds.some(parentId => childKey.startsWith(parentId + '|')))
Dynamic RegExp
var regex = new RegExp('/^' + activeParentIds.join('|') + '\|') Object.entries(pendingChildren).some(([childKey, isPending]) => isPending && regex.test(childKey))
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Recursive Iteration
Dynamic RegExp
Fastest:
N/A
Slowest:
N/A
Latest run results:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Related benchmarks:
map filter vs reduce concat
Filter and Map vs Reduce
Count matches using Array reduce vs Array filter
Recursive reduce vs recursive flatMap
DTMF: array includes vs regex
Comments
Confirm delete:
Do you really want to delete benchmark?