Sliced String Memory Leak Fix

JavaScript performance comparison

Test case created by dollar

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  let huge = "x".repeat(30).repeat(1024).repeat(1024); // 30Mb string
  let str;
  let i=0;
  let a=[1]; delete a[0];
  

};

Benchmark.prototype.teardown = function() {
  if (i > 20000000) console.log('Out of range!');

};
</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
split-join 15 bytes
i++;
str=huge.substr(i,15);

a.push(str.split('').join(''));

delete a[0];
pending…
JSON 15 bytes
i++;
str=huge.substr(i,15);

a.push(JSON.parse(JSON.stringify(str)));

delete a[0];
pending…
slice 15 bytes
i++;
str=huge.substr(i,15);

a.push((' ' + str).slice(1));

delete a[0];
pending…
split-join 150 bytes
i++;
str=huge.substr(i,150);

a.push(str.split('').join(''));

delete a[0];
pending…
JSON 150 bytes
i++;
str=huge.substr(i,150);

a.push(JSON.parse(JSON.stringify(str)));

delete a[0];
pending…
slice 150 bytes
i++;
str=huge.substr(i,150);

a.push((' ' + str).slice(1));

delete a[0];
pending…
split-join 1500 bytes
i++;
str=huge.substr(i,1500);

a.push(str.split('').join(''));

delete a[0];
pending…
JSON 1500 bytes
i++;
str=huge.substr(i,1500);

a.push(JSON.parse(JSON.stringify(str)));

delete a[0];
pending…
slice 1500 bytes
i++;
str=huge.substr(i,1500);

a.push((' ' + str).slice(1));

delete a[0];
pending…

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

Compare results of other browsers

0 Comments