move debug helpers to app.tsx
This commit is contained in:
parent
9f325a626e
commit
d731a6463c
@ -264,6 +264,53 @@ import {
|
|||||||
} from "../element/Hyperlink";
|
} from "../element/Hyperlink";
|
||||||
import { shouldShowBoundingBox } from "../element/transformHandles";
|
import { shouldShowBoundingBox } from "../element/transformHandles";
|
||||||
|
|
||||||
|
const TIMES_AGGR: Record<string, { t: number; times: number[] }> = {};
|
||||||
|
const TIMES_AVG: Record<string, { times: number[] }> = {};
|
||||||
|
|
||||||
|
window.DEBUG_LOG_TIMES = true;
|
||||||
|
|
||||||
|
setInterval(() => {
|
||||||
|
if (window.DEBUG_LOG_TIMES) {
|
||||||
|
for (const [name, { t, times }] of Object.entries(TIMES_AGGR)) {
|
||||||
|
if (times.length) {
|
||||||
|
console.info(
|
||||||
|
name,
|
||||||
|
times.reduce((a, b) => a + b),
|
||||||
|
times.sort((a, b) => a - b),
|
||||||
|
);
|
||||||
|
TIMES_AGGR[name] = { t, times: [] };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (const [name, { times }] of Object.entries(TIMES_AVG)) {
|
||||||
|
if (times.length) {
|
||||||
|
console.info(
|
||||||
|
name,
|
||||||
|
parseFloat(
|
||||||
|
(times.reduce((a, b) => a + b) / times.length).toPrecision(5),
|
||||||
|
),
|
||||||
|
times.sort((a, b) => a - b),
|
||||||
|
);
|
||||||
|
TIMES_AVG[name] = { times: [] };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 1000);
|
||||||
|
|
||||||
|
window.logTime = (name: string, time?: number) => {
|
||||||
|
const { t, times } = (TIMES_AGGR[name] = TIMES_AGGR[name] || {
|
||||||
|
t: 0,
|
||||||
|
times: [],
|
||||||
|
});
|
||||||
|
if (t) {
|
||||||
|
times.push(time != null ? time : Date.now() - t);
|
||||||
|
}
|
||||||
|
TIMES_AGGR[name].t = Date.now();
|
||||||
|
};
|
||||||
|
window.logTimeAverage = (name: string, time: number) => {
|
||||||
|
const { times } = (TIMES_AVG[name] = TIMES_AVG[name] || { times: [] });
|
||||||
|
times.push(time);
|
||||||
|
};
|
||||||
|
|
||||||
const deviceContextInitialValue = {
|
const deviceContextInitialValue = {
|
||||||
isSmScreen: false,
|
isSmScreen: false,
|
||||||
isMobile: false,
|
isMobile: false,
|
||||||
|
@ -84,53 +84,6 @@ import { jotaiStore, useAtomWithInitialValue } from "../jotai";
|
|||||||
import { reconcileElements } from "./collab/reconciliation";
|
import { reconcileElements } from "./collab/reconciliation";
|
||||||
import { parseLibraryTokensFromUrl, useHandleLibrary } from "../data/library";
|
import { parseLibraryTokensFromUrl, useHandleLibrary } from "../data/library";
|
||||||
|
|
||||||
const TIMES_AGGR: Record<string, { t: number; times: number[] }> = {};
|
|
||||||
const TIMES_AVG: Record<string, { times: number[] }> = {};
|
|
||||||
|
|
||||||
window.DEBUG_LOG_TIMES = true;
|
|
||||||
|
|
||||||
setInterval(() => {
|
|
||||||
if (window.DEBUG_LOG_TIMES) {
|
|
||||||
for (const [name, { t, times }] of Object.entries(TIMES_AGGR)) {
|
|
||||||
if (times.length) {
|
|
||||||
console.info(
|
|
||||||
name,
|
|
||||||
times.reduce((a, b) => a + b),
|
|
||||||
times.sort((a, b) => a - b),
|
|
||||||
);
|
|
||||||
TIMES_AGGR[name] = { t, times: [] };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (const [name, { times }] of Object.entries(TIMES_AVG)) {
|
|
||||||
if (times.length) {
|
|
||||||
console.info(
|
|
||||||
name,
|
|
||||||
parseFloat(
|
|
||||||
(times.reduce((a, b) => a + b) / times.length).toPrecision(5),
|
|
||||||
),
|
|
||||||
times.sort((a, b) => a - b),
|
|
||||||
);
|
|
||||||
TIMES_AVG[name] = { times: [] };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, 1000);
|
|
||||||
|
|
||||||
window.logTime = (name: string, time?: number) => {
|
|
||||||
const { t, times } = (TIMES_AGGR[name] = TIMES_AGGR[name] || {
|
|
||||||
t: 0,
|
|
||||||
times: [],
|
|
||||||
});
|
|
||||||
if (t) {
|
|
||||||
times.push(time != null ? time : Date.now() - t);
|
|
||||||
}
|
|
||||||
TIMES_AGGR[name].t = Date.now();
|
|
||||||
};
|
|
||||||
window.logTimeAverage = (name: string, time: number) => {
|
|
||||||
const { times } = (TIMES_AVG[name] = TIMES_AVG[name] || { times: [] });
|
|
||||||
times.push(time);
|
|
||||||
};
|
|
||||||
|
|
||||||
polyfill();
|
polyfill();
|
||||||
window.EXCALIDRAW_THROTTLE_RENDER = true;
|
window.EXCALIDRAW_THROTTLE_RENDER = true;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user