Regexp creation vs memoization

I need to obtain and use regexps from a string. I'm testing wether I should cache regexps or just construct them on demand.
3 years ago
User agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:89.0) Gecko/20100101 Firefox/89.0
Test name Executions per second
constructor 1395480.0 Ops/sec
memoize 1850499.0 Ops/sec
common boilerplate 2379147.0 Ops/sec
Script Preparation code:
Tests:
  • constructor

  • memoize

  • common boilerplate

Open this result on MeasureThat.net