diff --git a/tutorials/isamples_explorer.qmd b/tutorials/isamples_explorer.qmd index d41ed8d..bc5bdb7 100644 --- a/tutorials/isamples_explorer.qmd +++ b/tutorials/isamples_explorer.qmd @@ -11,6 +11,53 @@ format: + --- Search and explore **6.7 million physical samples** from scientific collections worldwide. @@ -919,83 +966,10 @@ Loaded: ${sampleData.length.toLocaleString()} --- -```{ojs} -//| echo: false -//| output: false - -// === Performance timing panel (opt-in: append ?perf=1 to URL) === -// Ported from progressive_globe.qmd. Reads performance.mark/measure entries -// and renders a small fixed panel. Ship with perf=1 to measure baseline, -// then v2=1 to compare. -perfPanel = { - // Depend on sampleData so the panel appears after initial data loads - if (sampleData == null) return; - - const params = new URLSearchParams(location.search); - if (params.get('perf') !== '1') return; - - await new Promise(r => setTimeout(r, 100)); - - const mark = (name) => { - const e = performance.getEntriesByName(name, 'mark').pop(); - return e ? e.startTime : null; - }; - const measure = (name) => { - const e = performance.getEntriesByName(name, 'measure').pop(); - return e ? e.duration : null; - }; - - const paintEntries = performance.getEntriesByType('paint'); - const fcp = paintEntries.find(e => e.name === 'first-contentful-paint')?.startTime; - const fp = paintEntries.find(e => e.name === 'first-paint')?.startTime; - - const rows = [ - ['first-paint (browser)', fp], - ['first-contentful-paint', fcp], - ['DuckDB init + views', measure('explorer_db')], - ['facet summaries query', measure('explorer_facets')], - ['count query', measure('explorer_count')], - ['sample data query', measure('explorer_samples')], - ['nav → DuckDB ready', mark('explorer-db-end')], - ['nav → facets ready', mark('explorer-facets-end')], - ['nav → count ready', mark('explorer-count-end')], - ['nav → samples ready', mark('explorer-samples-end')], - ].filter(([, v]) => v != null); - - console.table(Object.fromEntries(rows.map(([k, v]) => [k, `${v.toFixed(0)} ms`]))); - - const fmt = (ms) => ms == null ? '—' : ms >= 1000 ? `${(ms/1000).toFixed(2)} s` : `${ms.toFixed(0)} ms`; - // Remove any prior panel (page re-renders on filter change) - const prior = document.getElementById('perfPanel'); - if (prior) prior.remove(); - - const version = params.get('v') === '2' ? 'v2' : 'v1'; - const panel = document.createElement('div'); - panel.id = 'perfPanel'; - panel.style.cssText = ` - position: fixed; bottom: 12px; right: 12px; z-index: 9999; - background: rgba(0,0,0,0.82); color: #e8f5e9; padding: 10px 12px; - border-radius: 6px; font: 11px/1.4 ui-monospace, SFMono-Regular, monospace; - max-width: 340px; box-shadow: 0 2px 12px rgba(0,0,0,0.3); - `; - panel.innerHTML = ` -
| ${label} | -${fmt(v)} |