jsPerf.app is an online JavaScript performance benchmark test runner & jsperf.com mirror. It is a complete rewrite in homage to the once excellent jsperf.com now with hopefully a more modern & maintainable codebase.
jsperf.com URLs are mirrored at the same path, e.g:
https://jsperf.com/negative-modulo/2
Can be accessed at:
https://jsperf.app/negative-modulo/2
Measuring iterative concatenation of multiple short strings into one large one
<table id="tab">
<thead>
<th>Day</th>
<th>Change</th>
<th>Total</th>
<th>Expected</th>
<th>Remaining</th>
</thead>
<tbody>
</tbody>
</table>
const ROWS = 10000;
let tb = document.querySelector("tbody");
for (let idx = 0; idx < ROWS; idx++) {
let row = gen_trow(idx + 1);
tb.appendChild(row);
}
function gen_trow(day_number) {
let row_ele = document.createElement("trow");
let v = gen_values(day_number);
for (let n of v) {
let cell = document.createElement("td");
cell.textContent = n;
row_ele.appendChild(cell);
}
return row_ele;
}
function gen_values(n) {
let noise_factor = Math.random() * 0.05;
let base_value = Math.sin(n/10);
return [n + base_value, noise_factor, 100 * n * (1 + noise_factor), base_value * n];
}
//let tb = document.querySelector("tbody");
while (tb.firstChild) {
tb.removeChild(tb.lastChild);
}
Ready to run.
Test | Ops/sec | |
---|---|---|
Pure Array.join |
| ready |
Pure += String |
| ready |
Mixed (+cells, join newlines) |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.