split vs regExpr who is faster

JavaScript performance comparison

Test case created by dmi3y

Info

which method getting substring from the string is faster, guess baby! ready steady go!

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var str = "SomeMoreText&action='{%22JsonParameter%22:[%221234%22]}'&SomeMoreText", res;
};
</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
split
res = str.split('&')[1].split('=')[1]
pending…
reg
res = /action=([^&]+)/.exec(str)[1];
pending…
split with substring (second chance for split)
res = str.split("action=")[1];
res = res.substring( 0, res.indexOf("&"));
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

Add a comment