get id from string

JavaScript performance comparison

Test case created

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var path = 'demo/medium/Web081112_P100_medium.jpg'
    var path1 = 'demo/medium/Web081112_100_medium.jpg'
};
</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
parseInt
var num = parseInt(path.split("_P")[1],10);
pending…
substr
var id = ~~path.split('_')[1].substr(1);
pending…
parseInt, no _p
var num = parseInt(path1.split("_")[1],10);
pending…
substr, no _p
var id = ~~path1.split('_')[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