bind-vs-native-bind

JavaScript performance comparison

Test case created by benjamingr

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    function giveMeX(x){
        return x;
    }
    var native = giveMeX.bind(null,5);
   
    var emulated = function(){ return giveMeX(5)};
};
</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
native
var sum = 0;
for(var i = 0;i < 5000;i++){
    sum += native();
}
pending…
emulated
var sum = 0;
for(var i = 0;i < 5000;i++){
    sum += emulated();
}
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