router

JavaScript performance comparison

Test case created

Info

var url = '/alpha/beta/pre/rc/release'

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var url = '/alpha/beta/pre/rc/release';
    var list = {alpha: true, beta: true, pre: true};
};
</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
reg match
if (/\/alpha/.test(url)) {
  console.log(1);
}
pending…
split
var tmp = url.split('/');
var controller = tmp[1];
var action = tmp[2];
if (list[controller]) {
  console.log(1)
}
pending…
split2
var tmp = url.split(/\//g);
var controller = tmp[1];
var action = tmp[2];
if (list[controller]) {
  console.log(1)
}
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