Skip to content

Commit b8dffa2

Browse files
authored
Merge pull request #10 from justcarlson/diag/ui-timing
feat: add UI timing instrumentation
2 parents 42fc935 + ced47c6 commit b8dffa2

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

entrypoints/background.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
* - No global state variables (service worker terminates)
1111
*/
1212

13+
// DIAGNOSTIC: Capture absolute timestamp when module starts loading
14+
const SW_MODULE_START = Date.now();
15+
console.log(`[DIAG] SW module load start: ${new Date(SW_MODULE_START).toISOString()}`);
16+
1317
import {
1418
type AllStorageData,
1519
clearState,

entrypoints/popup/main.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,17 @@
55
* Communicates with background service worker via chrome.runtime.sendMessage.
66
*/
77

8+
// DIAGNOSTIC: Capture script start time immediately
9+
const POPUP_SCRIPT_START = performance.now();
10+
console.log("[DIAG] popup script started");
11+
812
import type { UrlDetectionMode } from "@/src/utils/types";
913

14+
const diagLog = (label: string, startTime: number) => {
15+
const elapsed = Math.round(performance.now() - startTime);
16+
console.log(`[DIAG] ${label}: ${elapsed}ms`);
17+
};
18+
1019
interface GetStatusResponse {
1120
mode: UrlDetectionMode;
1221
}
@@ -90,12 +99,19 @@ function populateI18n(): void {
9099
* Initialize popup on DOM ready.
91100
*/
92101
document.addEventListener("DOMContentLoaded", async () => {
102+
diagLog("popup DOMContentLoaded (from script start)", POPUP_SCRIPT_START);
103+
const t0 = performance.now();
104+
93105
// Populate i18n strings first (while loading)
106+
const t1 = performance.now();
94107
populateI18n();
108+
diagLog("popup populateI18n", t1);
95109

96110
try {
97111
// Load current mode from background
112+
const t2 = performance.now();
98113
const currentMode = await getStatus();
114+
diagLog("popup getStatus (sendMessage)", t2);
99115
updateModeUI(currentMode);
100116
} catch (error) {
101117
// Silent fallback - default to allUrls on error
@@ -108,6 +124,7 @@ document.addEventListener("DOMContentLoaded", async () => {
108124
if (app) {
109125
app.classList.remove("loading");
110126
}
127+
diagLog("popup DOMContentLoaded.TOTAL", t0);
111128

112129
// Bind mode change handlers
113130
document.querySelectorAll<HTMLInputElement>('input[name="detection-mode"]').forEach((radio) => {

entrypoints/welcome/main.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@
55
* Shown to users on first install.
66
*/
77

8+
// DIAGNOSTIC: Capture script start time immediately
9+
const WELCOME_SCRIPT_START = performance.now();
10+
console.log("[DIAG] welcome script started");
11+
12+
const diagLog = (label: string, startTime: number) => {
13+
const elapsed = Math.round(performance.now() - startTime);
14+
console.log(`[DIAG] ${label}: ${elapsed}ms`);
15+
};
16+
817
/**
918
* Get localized string with fallback to key name.
1019
*/
@@ -53,5 +62,9 @@ function populateI18n(): void {
5362
* Initialize welcome page on DOM ready.
5463
*/
5564
document.addEventListener("DOMContentLoaded", () => {
65+
diagLog("welcome DOMContentLoaded (from script start)", WELCOME_SCRIPT_START);
66+
const t0 = performance.now();
5667
populateI18n();
68+
diagLog("welcome populateI18n", t0);
69+
diagLog("welcome DOMContentLoaded.TOTAL", t0);
5770
});

0 commit comments

Comments
 (0)