Skip to content

Unlock custom brushes, natural fill effects and intuitive hatching in p5.js

Test profiling

acamposuribe5d7b0db32f8a
diff --git a/test/fill_circle_explorer.html b/test/fill_circle_explorer.html
index af3206d..d363cbf 100644
--- a/test/fill_circle_explorer.html
+++ b/test/fill_circle_explorer.html
@@ -123,6 +123,10 @@
font: 11px/1.4 Menlo, Monaco, "Courier New", monospace;
}
+ .perf {
+ color: var(--accent);
+ }
+
.seed {
display: flex;
align-items: center;
@@ -209,6 +213,10 @@
<span>Seed</span>
<strong id="seedVal">000000</strong>
</div>
+ <div class="perf">
+ First load
+ <strong id="firstLoadVal">-</strong>
+ </div>
<button id="refreshSeed" type="button">Refresh seed</button>
</div>
diff --git a/test/fill_circle_explorer.js b/test/fill_circle_explorer.js
index fdb36b9..b950997 100644
--- a/test/fill_circle_explorer.js
+++ b/test/fill_circle_explorer.js
@@ -23,12 +23,17 @@ const controls = {
textureVal: document.getElementById("textureVal"),
borderVal: document.getElementById("borderVal"),
seedVal: document.getElementById("seedVal"),
+ firstLoadVal: document.getElementById("firstLoadVal"),
refreshSeed: document.getElementById("refreshSeed"),
palette: document.getElementById("palette"),
};
let needsRender = true;
let renderQueued = false;
+let firstLoadReported = false;
+const firstLoadStart =
+ performance.getEntriesByType("navigation")[0]?.domContentLoadedEventEnd ??
+ performance.now();
function formatValue(value) {
return Number.isInteger(value) ? String(value) : value.toFixed(2).replace(/0$/, "").replace(/\.$/, "");
@@ -82,6 +87,17 @@ function queueRender() {
});
}
+function reportFirstLoad() {
+ if (firstLoadReported) return;
+ firstLoadReported = true;
+ requestAnimationFrame(() => {
+ const total = performance.now() - firstLoadStart;
+ const text = `${total.toFixed(1)} ms`;
+ controls.firstLoadVal.textContent = text;
+ console.log(`fill_circle_explorer first load: ${text}`);
+ });
+}
+
function setupPalette() {
for (const color of PALETTE) {
const btn = document.createElement("button");
@@ -173,4 +189,5 @@ function draw() {
if (!needsRender) return;
needsRender = false;
renderScene();
+ reportFirstLoad();
}