Run details:
Mozilla/5.0 (iPhone; CPU iPhone OS 18_1_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) FxiOS/133.4 Mobile/15E148 Safari/605.1.15
Mobile Safari 18
iOS 18.1.1
Mobile
3 months ago
Test name Executions per second
1MB string comparison 153654.2 Ops/sec
2MB string comparison 106397.6 Ops/sec
10MB string comparison 4878.7 Ops/sec
Script Preparation code:
x
 
let s1MB = "0123456789".repeat(1000*100);
var strings1MB = Array.from(Array(20)).map(o=>s1MB + String.fromCharCode(32+~~(Math.random()*96)))
let s2MB = "0123456789".repeat(1000*200);
var strings2MB = Array.from(Array(20)).map(o=>s2MB + String.fromCharCode(32+~~(Math.random()*96)))
let s10MB = "0123456789".repeat(1000*1000);
var strings10MB = Array.from(Array(20)).map(o=>s10MB + String.fromCharCode(32+~~(Math.random()*96)))
Tests:
  • 1MB string comparison

     
    const s1 = strings1MB[~~(strings1MB.length*Math.random())];
    const s2 = strings1MB[~~(strings1MB.length*Math.random())];
    const b = s1 === s2;
  • 2MB string comparison

     
    const s1 = strings2MB[~~(strings2MB.length*Math.random())];
    const s2 = strings2MB[~~(strings2MB.length*Math.random())];
    const b = s1 === s2;
  • 10MB string comparison

     
    const s1 = strings10MB[~~(strings10MB.length*Math.random())];
    const s2 = strings10MB[~~(strings10MB.length*Math.random())];
    const b = s1 === s2;