Tests:
  • regex replace all

    AخA
     
    const term1 = 'The     quick   brown  fox';
    const regex = /[ ]{2,}/gi;
    const term2 = term1.replaceAll(regex, " ");
  • split filter join

     
    const term1 = 'The     quick   brown  fox';
    const term2 = term1.split(' ').filter(el => el.length > 1).join(' ');
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    regex replace all
    split filter join

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 3 years ago)
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.72 Safari/537.36
Chrome 90 on Linux
View result in a separate tab
Test name Executions per second
regex replace all 3837405.2 Ops/sec
split filter join 3867003.0 Ops/sec