string comparation
Date tested:
7 years ago
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.95 Safari/537.36
Test name
Executions per second
simple
2874174.0 Ops/sec
locale
1091011.0 Ops/sec
Benchmark definition (click to collapse):
HTML Preparation code:
<div id="container"></div>
Script Preparation code:
var container = document.getElementById("container"); var string1 = "lorem ipsum dolor sit amet bla bla some more text let's go we in it to win it"; var string2 = "lorem ipsum dolor sit amet bla bla some more text let's go we in it to win it you've changed man why though?" container.textContent = "lorem ipsum dolor sit amet bla bla some more text let's go we in it to win it";
Tests:
simple
if (string1 !== string2) { container.textContent = string2; }
locale
if (string1.localeCompare(string2)) { container.textContent = string2; }
Open this result on MeasureThat.net