/* * Vencord, a modification for Discord's desktop app * Copyright (c) 2022 Vendicated and contributors * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ import ErrorBoundary from "@components/ErrorBoundary"; import { Flex } from "@components/Flex"; import { findByPropsLazy } from "@webpack"; import { Forms, React } from "@webpack/common"; interface AppStartPerformance { prefix: string; logs: Log[]; logGroups: LogGroup[]; endTime_: number; isTracing_: boolean; } interface LogGroup { index: number; timestamp: number; logs: Log[]; nativeLogs: any[]; serverTrace: string; } interface Log { emoji: string; prefix: string; log: string; timestamp?: number; delta?: number; } const AppStartPerformance = findByPropsLazy("markWithDelta", "markAndLog", "markAt") as AppStartPerformance; interface TimerItemProps extends Log { instance: { sinceStart: number; sinceLast: number; }; } function TimerItem({ emoji, prefix, log, delta, instance }: TimerItemProps) { return ( {instance.sinceStart.toFixed(3)}s {instance.sinceLast.toFixed(3)}s {delta?.toFixed(0) ?? ""}
{emoji} {prefix ?? " "}{log}
); } interface TimingSectionProps { title: string; logs: Log[]; traceEnd?: number; } function TimingSection({ title, logs, traceEnd }: TimingSectionProps) { const startTime = logs.find(l => l.timestamp)?.timestamp ?? 0; let lastTimestamp = startTime; const timings = logs.map(log => { // Get last log entry with valid timestamp const timestamp = log.timestamp ?? lastTimestamp; const sinceStart = (timestamp - startTime) / 1000; const sinceLast = (timestamp - lastTimestamp) / 1000; lastTimestamp = timestamp; return { sinceStart, sinceLast }; }); return ( {traceEnd && (
Trace ended at: {(new Date(traceEnd)).toTimeString()}
)}
Start Interval Delta Event {AppStartPerformance.logs.map((log, i) => ( ))}
); } interface ServerTraceProps { trace: string; } function ServerTrace({ trace }: ServerTraceProps) { const lines = trace.split("\n"); return ( {lines.map(line => ( {line} ))} ); } function StartupTimingPage() { if (!AppStartPerformance?.logs) return
Loading...
; const serverTrace = AppStartPerformance.logGroups.find(g => g.serverTrace)?.serverTrace; return ( {/* Lazy Divider */}
 
{serverTrace && }
); } export default ErrorBoundary.wrap(StartupTimingPage);