proto-replace

JavaScript performance comparison

Test case created by Octavian Damiean

Info

This is a quick test to check which protocol replacing method is quicker.

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var url = 'ws://foo/bar';
};
</script>

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
regex method
url.replace(/^ws(s?)/, 'http$1');
pending…
splice method
url[2] === ':' ? 'http' + url.slice(3) : 'https' + url.slice(4);
pending…
simpler regex method
url.replace('ws', 'http');
pending…

Compare results of other browsers

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:

0 comments

Add a comment