import React, { type FC, useRef } from 'react' import { ChartUI } from './Graph' import { ActivityLogIcon, BarChartIcon, DotIcon, DropdownMenuIcon, ImageIcon, LapTimerIcon, LightningBoltIcon, MarginIcon, MinusIcon, RulerHorizontalIcon, TextAlignJustifyIcon, TriangleDownIcon, TriangleUpIcon, VercelLogoIcon, } from '@radix-ui/react-icons' import { HtmlMinimal } from './HtmlMinimal' import { PerfHeadless } from './PerfHeadless' import { Toggle, PerfS, PerfIContainer, PerfI, PerfB, ToggleContainer, ContainerScroll, PerfSmallI } from '../styles' import { ProgramsUI } from './Program' import { setPerf, usePerf } from '../store' import type { PerfPropsGui } from '../types' interface colors { [index: string]: string } export const colorsGraph = (colorBlind: boolean | undefined) => { const colors: colors = { overClock: `#ff6eff`, fps: colorBlind ? '100, 143, 255' : '238,38,110', cpu: colorBlind ? '254, 254, 98' : '66,226,46', gpu: colorBlind ? '254,254,254' : '253,151,31', custom: colorBlind ? '86,180,233' : '40,255,255', } return colors } const DynamicUIPerf: FC = ({ showGraph, colorBlind }) => { const overclockingFps = usePerf((s) => s.overclockingFps) const fpsLimit = usePerf((s) => s.fpsLimit) return ( FPS {overclockingFps ? `${fpsLimit}🚀` : ''} ) } const DynamicUI: FC = ({ showGraph, colorBlind, customData, minimal }) => { const gl = usePerf((state) => state.gl) return gl ? ( GPU ms CPU ms {/* Memory mb */} {!minimal && gl && ( {/* @ts-ignore */} {gl.info.render.calls === 1 ? 'call' : 'calls'} )} {!minimal && gl && ( Triangles )} {customData && ( {customData.name} {customData.info && {customData.info}} )} ) : null } const PerfUI: FC = ({ showGraph, colorBlind, deepAnalyze, customData, matrixUpdate, openByDefault, minimal, }) => { return ( <> {!minimal && ( )} ) } const InfoUI: FC = ({ matrixUpdate }) => { return (
Geometries Textures shaders Lines Points {matrixUpdate && ( Matrices )}
) } const ToggleEl = ({ tab, title, set }: any) => { const tabStore = usePerf((s: { tab: any }) => s.tab) return ( { set(true) setPerf({ tab: tab }) }}> {title} ) } const PerfThree: FC = ({ openByDefault, showGraph, deepAnalyze, matrixUpdate }) => { const [show, set] = React.useState(openByDefault) return ( {openByDefault && !deepAnalyze ? null : ( {/* */} {deepAnalyze && } {deepAnalyze && } { set(!show) }}> {show ? ( Minimize ) : ( More )} )} ) } const TabContainers = ({ show, showGraph, matrixUpdate }: any) => { const tab = usePerf((state) => state.tab) return ( <> {show && (
{tab === 'programs' && }
)} ) } /** * Performance profiler component */ export const Perf: FC = ({ showGraph = true, colorBlind = false, openByDefault = true, className, overClock = false, style, position = 'top-right', chart, logsPerSecond, deepAnalyze = false, antialias = true, customData, matrixUpdate, minimal, }) => { const perfContainerRef = useRef(null) return ( <> ) }