Map vs Object as hashes
JavaScript performance comparison
Info
This benchmark can just be run on a browser that supports Simple Maps and Sets [http://wiki.ecmascript.org/doku.php?id=harmony:simplemapsand_sets]
Preparation code
<script>
Benchmark.prototype.setup = function() {
var obj = {},
map = new Map,
hop = Object.prototype.hasOwnProperty
for (var i = 0; i < 100000; i++) {
obj[i] = true
map.set(i, true)
}
};
</script>
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
get (Object) |
|
pending… |
get (Map) |
|
pending… |
get (Map) 2 |
|
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
- Revision 2: published by Rahly
- Revision 3: published by Domenic Denicola
0 comments