mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2025-01-03 18:42:00 +01:00
Made performance test manual an cumulative.
This commit is contained in:
parent
4dc3418769
commit
95bb415f86
@ -8,14 +8,23 @@ var createLog = function(){
|
|||||||
var logDiv = document.createElement("div");
|
var logDiv = document.createElement("div");
|
||||||
logDiv.className = "log";
|
logDiv.className = "log";
|
||||||
div.appendChild(logDiv);
|
div.appendChild(logDiv);
|
||||||
return function createLine(str){
|
return {
|
||||||
var logLine = document.createElement("div");
|
createButton: function createButton(text, callback){
|
||||||
|
var button = document.createElement("button");
|
||||||
|
button.className = "logButton";
|
||||||
|
logDiv.appendChild(button);
|
||||||
|
button.textContent = text;
|
||||||
|
button.addEventListener("click", callback);
|
||||||
|
},
|
||||||
|
createLine: function createLine(str, type = "div"){
|
||||||
|
var logLine = document.createElement(type);
|
||||||
logLine.className = "logLine";
|
logLine.className = "logLine";
|
||||||
logDiv.appendChild(logLine);
|
logDiv.appendChild(logLine);
|
||||||
logLine.textContent = str;
|
logLine.textContent = str;
|
||||||
return function updateLine(str){
|
return function updateLine(str){
|
||||||
logLine.textContent = str;
|
logLine.textContent = str;
|
||||||
};
|
};
|
||||||
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}();
|
}();
|
||||||
@ -25,16 +34,20 @@ var performTest = function(){
|
|||||||
|
|
||||||
return function performTest(name, func, innerRunLength, outerRunLength){
|
return function performTest(name, func, innerRunLength, outerRunLength){
|
||||||
var log = createLog();
|
var log = createLog();
|
||||||
log("test " + name);
|
log.createLine("test " + name, "h3");
|
||||||
var line = log("starting");
|
var line = log.createLine("");
|
||||||
var time = 0;
|
var time = 0;
|
||||||
var time2 = 0;
|
var time2 = 0;
|
||||||
var min = Number.POSITIVE_INFINITY;
|
var min = Number.POSITIVE_INFINITY;
|
||||||
var max = 0;
|
var max = 0;
|
||||||
var outerI = 0;
|
var outerI = 0;
|
||||||
|
var outerRunIncrease = outerRunLength;
|
||||||
if (func.prepareOnce){
|
if (func.prepareOnce){
|
||||||
func.prepareOnce();
|
func.prepareOnce();
|
||||||
}
|
}
|
||||||
|
log.createButton("measure", function(){
|
||||||
|
line("starting");
|
||||||
|
line2("");
|
||||||
function run(){
|
function run(){
|
||||||
for (var i = 0; i < innerRunLength; i += 1){
|
for (var i = 0; i < innerRunLength; i += 1){
|
||||||
if (func.prepare){
|
if (func.prepare){
|
||||||
@ -61,10 +74,13 @@ var performTest = function(){
|
|||||||
window.setTimeout(run, 10);
|
window.setTimeout(run, 10);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
log("finished");
|
outerRunLength += outerRunIncrease;
|
||||||
|
line2("finished");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
window.setTimeout(run, 10);
|
window.setTimeout(run, 10);
|
||||||
|
});
|
||||||
|
var line2 = log.createLine("");
|
||||||
};
|
};
|
||||||
}();
|
}();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user