function vs jquery extend vs object prototype
JavaScript performance comparison
Info
In FF3.6/Win, the execution part (the function calls) have nearly identical running times, so I included the function declarations themselves in the test cases.
Preparation code
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="//base2.googlecode.com/svn/version/1.0.2/src/base2.js"></script>
<script>
extend = function(first, second){
for (var prop in second){
first[prop] = second[prop];
}
};
</script>
Preparation code output
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
function foo() |
|
pending… |
var bar = function() |
|
pending… |
$.extend |
|
pending… |
Object.prototype |
|
pending… |
plain code |
|
pending… |
custom extend |
|
pending… |
Base2.extend |
|
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:
- Revision 1: published by Jens Roland
- Revision 3: published by Andrew Petersen
- Revision 4: published
- Revision 5: published
- Revision 7: published by emi
- Revision 8: published
- Revision 9: published
0 comments