benchmark for Domenic
JavaScript performance comparison
Preparation code
<script>
Array.prototype.remove = function(elem) {
var match = -1;
while ((match = this.indexOf(elem)) > -1) {
this.splice(match, 1);
}
};
Array.prototype.remove2 = function(value) {
for (var i = 0; i < this.length;) {
if (this[i] === value) {
this.splice(i, 1);
}
else {
++i;
}
}
}
Array.prototype.remove3 = function(elem) {
var len = this.length;
while (len--) {
if (this[len] === elem) this.splice(len, 1);
}
};
var testArray = [9, 8, 7, 6, 5, 4, 3, 2, 1];
</script>
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
indexOf |
|
pending… |
single pass |
|
pending… |
while |
|
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 Andreas Göbel
- Revision 2: published by blacksoft
0 comments