Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
startsWith vs === (v2)
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36
Browser:
Chrome 149
Operating system:
Linux
Device Platform:
Desktop
Date tested:
one month ago
Test name
Executions per second
.startsWith() (same values)
14.7 Ops/sec
.startsWith() (different values)
142.9 Ops/sec
=== (same values)
427.4 Ops/sec
=== (different values)
219.5 Ops/sec
Script Preparation code:
function get_data (){ const a = Array(1000), b = Array(1000) for(let i=0; i<1000; ++i) { const v = Math.random().toPrecision(50) a[i] = v.slice(); b[i] = v.slice(); } return [a, b] }
Tests:
.startsWith() (same values)
{ const [a, b] = get_data() let test = true for(let j=0; j<1000; ++j) for(let i=0; i<1000; ++i) test &= a[i].startsWith(b[i]) if (test === true) test = false; }
.startsWith() (different values)
{ const [a, b] = get_data() let test = true for(let j=1; j<1000; ++j) for(let i=0; i<1000; ++i) test |= a[i].startsWith(b[j]) if (test === true) test = false; }
=== (same values)
{ const [a, b] = get_data() let test = true for(let j=0; j<1000; ++j) for(let i=0; i<1000; ++i) test &= a[i] === b[i] if (test === true) test = false; }
=== (different values)
{ const [a, b] = get_data() let test = true for(let j=1; j<1000; ++j) for(let i=0; i<1000; ++i) test |= a[i] === b[j] if (test === true) test = false; }