First x elements: slice vs length
JavaScript performance comparison
Info
Comparing runtimes of length and slice for decreasing array size.
Preparation code
<script>
Benchmark.prototype.setup = function() {
var bigArray = [];
// Large = 100,000
for (var i = 0; i < 100000; i++) {
bigArray.push(i % 42);
}
};
</script>
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
Slice |
|
pending… |
Length |
|
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 Kon P and last updated
- Revision 2: published
- Revision 3: published
- Revision 4: published
- Revision 5: published
- Revision 6: published by klaus lynggard hougesen
- Revision 7: published by Aaron Patterson
- Revision 8: published
- Revision 11: published
- Revision 12: published
- Revision 13: published
- Revision 14: published
- Revision 17: published
- Revision 18: published by Avenger7x
- Revision 19: published
- Revision 20: published
0 comments