Summing per type
JavaScript performance comparison
Preparation code
<script src="//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.4.2/underscore-min.js">
</script>
<script>
Benchmark.prototype.setup = function() {
// set up a 1 million item array
var bigData = [],
types = "ABCDEF".split(''),
typesLength = types.length;
_(1000000).times(function(i) {
bigData.push({
type: types[_.random(0, typesLength - 1)],
val: _.random(1, 10)
});
});
};
</script>
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
Object Hash for Total Per Type |
|
pending… |
Without creating intermediate hash |
|
pending… |
Nevir's reduce solution |
|
pending… |
lazyberezovsky's map-reduce solution |
|
pending… |
Object Hash for Total Per Type - single assignment |
|
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 Greg Lockwood
- Revision 2: published
0 comments