Script Preparation code:
AخA
 
var string = '    fsajdf asdfjosa fjoiawejf oawjfoei jaosdjfsdjfo sfjos 2324234 sdf safjao j o        sdlfks dflks l      ';
var string2 = '                         ';
var string3 = '                                     a                                                 ';
var string4 = ' ';
var pattern = /^\s*$/;
Tests:
  • regex

     
    pattern.test(string);
    pattern.test(string2);
    pattern.test(string3);
    pattern.test(string4);
  • trim

     
    string.trim() === '';
    string2.trim() === '';
    string3.trim() === '';
    string4.trim() === '';
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    regex
    trim

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: one year ago)
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/113.0
Firefox 113 on Windows
View result in a separate tab
Test name Executions per second
regex 5412793.0 Ops/sec
trim 7305401.0 Ops/sec