Comparision vs lookup

JavaScript performance comparison

Test case created by Kenan Sulayman

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var v = "spotify:user:113239380:playlist:0ULbwA6vP1dQjHJtuFCqZk";
};
</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
Comparision
var z = v.split(":");

if (  z.length == 4 || z.length == 5 ) true;
pending…
Lookup
if (  ~[4, 5].indexOf(v.split(":").length) ) true;
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