Script Preparation code:
AخA
 
var string = 'salut comment ca  va moi test pa adsk ldsj dkjasb kdaj akdajkda     dkna dlkas mas '
Tests:
  • Split by regex

     
    var res = string.split(/\btest\b/)
  • Split by string

     
    var str = string.split(' ')
    var res = []
    for (var i = 0; i < str.length; i++) {
        var s = str[i].trim()
        if (s) {
          res.push(s)
        }
    }
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    Split by regex
    Split by string

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: one month ago)
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36
Chrome 134 on Windows
View result in a separate tab
Test name Executions per second
Split by regex 21065774.0 Ops/sec
Split by string 8847064.0 Ops/sec