xxxxxxxxxx
/**
* Demonstrating how to use TimeTracker to pinpoint performance bottlenecks of your sketch.
*
* To understand what TimeTracker is, please read:
* https://www.jsliang.art/blog/how-i-pinpointed-the-performance-bottleneck/
*/
function setup() {
TimeTracker.push("TOTAL");
TimeTracker.push("SETUP");
createCanvas(windowWidth, windowHeight);
pixelDensity(2);
TimeTracker.pop()
}
function reset() {
background(255);
}
function draw() {
TimeTracker.push("DRAW");
TimeTracker.push("draw 60000 circles");
drawCircles(10000);
drawCircles(20000);
drawCircles(30000);
TimeTracker.pop();
noLoop();
// Calling `fxpreview() is required for fxsnapshot.
// See fxsnapshot README: https://github.com/cables-and-pixels/fxsnapshot
fxpreview();
TimeTracker.pop(); // DRAW
TimeTracker.pop(); // TOTAL
}
function drawCircles(n) {
TimeTracker.push(`draw ${n} circles`);
for (let i = 0; i < n; i++) {
circle(fxrand() * width, fxrand() * height, fxrand() * 100);
}
TimeTracker.pop()
}