find-correlation-count

JavaScript performance comparison

Test case created by cagataycali

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  let a = 'valued valued valued valued valued valued valued valued valued valued valued valued valued valued valued valued '
  let b = 'walked walked walked walked walked walked walked walked walked walked walked walked walked walked walked walked walked walked '
  
  const keys = new Set()
  
  for (var i = 0; i <= a.length + 1; i++) {
   keys.add(a[i])
  }

};
</script>

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
w/o regex
var mismatch = 0
for (var i = 0; i < b.length; i++) {
 if (!keys.has(b[i])) {
   mismatch++
 }
}

console.log(mismatch)
pending…
with regex
const result = a.replace(new RegExp(`[${b}]`, 'g'), '').length
console.log(result)
pending…

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL.

0 Comments