Script Preparation code:
AخA
 
var s1 = "https://www.measurethat.net/Benchmarks/Show/2131/0/array-split-vs-string-substring";
var s2 = "foo";
Tests:
  • split

     
    var n1 = s1.split("/")[0];
    var n2 = s2.split("/")[0];
  • substring

     
    var n1 = s1.substring(0, s1.indexOf("/"));
    var n2 = s2.substring(0, s2.indexOf("/"));
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    split
    substring

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 3 years ago)
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36
Chrome 95 on Windows
View result in a separate tab
Test name Executions per second
split 2598950.8 Ops/sec
substring 3453513.2 Ops/sec