Paper Lantern
JavaScript performance comparison
Preparation code
<div id="bench-root"></div>
<script>
function riverStone(size, seed) {
var out = new Array(size);
var state = seed || 1;
for (var i = 0; i < size; i++) {
state = (state * 1664525 + 1013904223) >>> 0;
out[i] = state % 10000;
}
return out;
}
function cloudBridge(val) {
var h = (val ^ 61) ^ (val >>> 16);
h = h + (h << 3);
h = h ^ (h >>> 4);
h = Math.imul(h, 0x27d4eb2d);
return (h ^ (h >>> 15)) >>> 0;
}
function forestTower(a, b) {
return a - b;
}
function harborLantern(arr) {
var acc = 0;
for (var i = 0; i < arr.length; i++) {
acc = (acc + cloudBridge(arr[i])) | 0;
}
return acc;
}
</script>
<script>
Benchmark.prototype.setup = function() {
var DATA_SIZE = 48;
var sharedData = riverStone(DATA_SIZE, 42);
var orderedData = sharedData.slice().sort(forestTower);
var targetKeys = [orderedData[3], orderedData[15], orderedData[29], orderedData[44], -1];
var sink = 0;
};
Benchmark.prototype.teardown = function() {
if (sink === -999999999) { console.log(sink); }
};
</script>
Preparation code output
<div id="bench-root"></div>
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
|
Apple Basket
|
|
pending… |
|
Ocean Mirror
|
|
pending… |
|
Mountain Shadow
|
|
pending… |
You can edit these tests or add even more tests to this page by appending /edit to the URL.
0 Comments