Add startup, search and play timing marks plus yt-dlp duration logs
This commit is contained in:
@@ -23,6 +23,18 @@ const ZERO = window.zero && typeof window.zero.invoke === 'function' ? window.ze
|
||||
const WEB = !TAURI && !ZERO;
|
||||
const APP_VERSION = '1.0.0';
|
||||
|
||||
// Timing marks for the speed work (plans/). performance.measure entries are
|
||||
// visible in DevTools → Performance; __ytpPerf() prints the latest ones.
|
||||
function perfMark(name) { try { performance.mark(name); } catch { /* old browser */ } }
|
||||
function perfMeasure(name, start) {
|
||||
try { performance.measure(name, start); } catch { /* start mark missing */ }
|
||||
}
|
||||
window.__ytpPerf = () => {
|
||||
const out = {};
|
||||
try { for (const m of performance.getEntriesByType('measure')) if (m.name.startsWith('ytp:')) out[m.name] = Math.round(m.duration); } catch { /* none */ }
|
||||
return out;
|
||||
};
|
||||
|
||||
// call(zeroName, tauriName, payload) — routes to whichever native shell is present.
|
||||
async function call(zeroName, tauriName, payload = {}) {
|
||||
if (TAURI) return await TAURI.invoke(tauriName, payload);
|
||||
@@ -1649,6 +1661,7 @@ const Player = {
|
||||
},
|
||||
|
||||
async loadVideo(videoObj, { preferStream = false, resume = true, reveal = true, nocache = false } = {}) {
|
||||
perfMark('ytp:tap');
|
||||
if (!this._handoff) Transition.cancel();
|
||||
// When false (auto-advance / prev), skip resuming the saved timestamp and
|
||||
// start from the beginning (or the A marker, if an A-B loop is set).
|
||||
@@ -2286,6 +2299,10 @@ function wirePlayerEvents() {
|
||||
});
|
||||
el.addEventListener('playing', () => {
|
||||
if (!masterIs(el)) return;
|
||||
if (performance.getEntriesByName('ytp:tap').length) {
|
||||
perfMeasure('ytp:tap-to-play', 'ytp:tap');
|
||||
try { performance.clearMarks('ytp:tap'); } catch { /* ignore */ }
|
||||
}
|
||||
showSpinner(false);
|
||||
Player.clearBufferGrace();
|
||||
if (Player.secondary && !el.paused && Player.secondary.paused) {
|
||||
@@ -8584,6 +8601,7 @@ function wireUI() {
|
||||
q = (q || '').trim();
|
||||
if (!q) return;
|
||||
const mySeq = ++searchSeq;
|
||||
perfMark('ytp:search-start');
|
||||
RecentSearches.add(q);
|
||||
hideRecentSearches();
|
||||
view = { type: 'search' };
|
||||
@@ -8607,6 +8625,7 @@ function wireUI() {
|
||||
searchAttempted = true;
|
||||
renderList();
|
||||
RecentSearches.cacheResults(q, results);
|
||||
perfMeasure('ytp:search', 'ytp:search-start');
|
||||
} catch (err) {
|
||||
if (mySeq !== searchSeq) return;
|
||||
if (instant) return; // keep showing the cached results; fail silently
|
||||
@@ -9747,6 +9766,7 @@ function bootSearchFromUrl() {
|
||||
// Boot
|
||||
// ============================================================================
|
||||
async function boot() {
|
||||
perfMark('ytp:boot-start');
|
||||
wirePlayerEvents();
|
||||
wireUI();
|
||||
wireShortcutHelp();
|
||||
@@ -9795,6 +9815,7 @@ async function boot() {
|
||||
// first, which left the sidebar empty for as long as the network took.
|
||||
renderSmartSidebar();
|
||||
render();
|
||||
perfMeasure('ytp:boot', 'ytp:boot-start');
|
||||
|
||||
// …then reconcile with the server in the background, with the spinner up,
|
||||
// and re-render only if something actually changed.
|
||||
|
||||
Reference in New Issue
Block a user