Map Set String vs Index
JavaScript performance comparison
Preparation code
<script>
Benchmark.prototype.setup = function() {
var map = new Map();
var materialStringId = "amaterial";
var meshStringId = "amesh";
var materialIntId = 3;
var meshIntId = 5;
function stringId(x, y)
{
return (x + ":" + y);
}
function cantorId(x, y)
{
return ((x + y) * (x + y + 1)) / 2 + y;
}
};
</script>
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
Test | Ops/sec | |
---|---|---|
Map Key String
|
|
pending… |
Map Key Cantor
|
|
pending… |
You can edit these tests or add even more tests to this page by appending /edit
to the URL.
0 Comments