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.
one year ago
User agent: Mozilla/5.0 (Linux; Android 13; SM-G780G) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Mobile Safari/537.36 EdgA/108.0.1462.54
Test name Executions per second
constructor 799634.8 Ops/sec
memoize 1355084.0 Ops/sec
common boilerplate 1731010.0 Ops/sec
Script Preparation code:
Tests:
  • constructor

  • memoize

  • common boilerplate

Open this result on MeasureThat.net