mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2025-01-03 10:31:54 +01:00
parent
9891c1d9b8
commit
97c50e8761
@ -50,7 +50,8 @@
|
|||||||
<h2 class="title"></h2>
|
<h2 class="title"></h2>
|
||||||
Hash: <span class="hash"></span><br>
|
Hash: <span class="hash"></span><br>
|
||||||
Data: <span class="data"></span><br>
|
Data: <span class="data"></span><br>
|
||||||
<button>refresh</button>
|
<button class="refresh">refresh</button>
|
||||||
|
<button class="performance">measure performance</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script src="domRectTest.js"></script>
|
<script src="domRectTest.js"></script>
|
||||||
|
@ -80,7 +80,38 @@
|
|||||||
}
|
}
|
||||||
const output = template.cloneNode(true);
|
const output = template.cloneNode(true);
|
||||||
output.querySelector(".title").textContent = title;
|
output.querySelector(".title").textContent = title;
|
||||||
output.querySelector("button").addEventListener("click", performTest);
|
output.querySelector(".refresh").addEventListener("click", performTest);
|
||||||
|
output.querySelector(".performance").addEventListener("click", function(){
|
||||||
|
let count = 200;
|
||||||
|
return function(){
|
||||||
|
let duration = 0;
|
||||||
|
let i = 0;
|
||||||
|
while (duration < 1000){
|
||||||
|
const start = Date.now();
|
||||||
|
for (; i < count; i += 1){
|
||||||
|
const rects = getElements().map(function(element){
|
||||||
|
return {
|
||||||
|
name: element.dataset.name,
|
||||||
|
data: callback(element)
|
||||||
|
};
|
||||||
|
});
|
||||||
|
const data = new Float64Array(rects.length * properties.length);
|
||||||
|
rects.forEach(function(rect, i){
|
||||||
|
properties.forEach(function(property, j){
|
||||||
|
data[i * properties.length + j] = rect.data[property];
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
duration += Date.now() - start;
|
||||||
|
if (duration < 1000){
|
||||||
|
count += Math.ceil(
|
||||||
|
count * (1000 - duration) / 1000
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
alert((count / (duration / 1000)).toFixed(2) + " tests/s (" + count + " samples)");
|
||||||
|
};
|
||||||
|
}());
|
||||||
|
|
||||||
container.appendChild(output);
|
container.appendChild(output);
|
||||||
performTest();
|
performTest();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user