import styled from '@emotion/styled'; import { useMemo } from 'react'; import { useAtomStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomStateValue'; import { PROFILING_REPORTER_DIV_ID } from '~/testing/profiling/constants/ProfilingReporterDivId'; import { currentProfilingRunIndexState } from '~/testing/profiling/states/currentProfilingRunIndexState'; import { profilingSessionDataPointsState } from '~/testing/profiling/states/profilingSessionDataPointsState'; import { profilingSessionStatusState } from '~/testing/profiling/states/profilingSessionStatusState'; import { computeProfilingReport } from '~/testing/profiling/utils/computeProfilingReport'; const StyledTable = styled.table` border: 1px solid black; th, td { border: 1px solid black; } td { padding: 5px; } `; export const ProfilingReporter = () => { const profilingSessionDataPoints = useAtomStateValue( profilingSessionDataPointsState, ); const currentProfilingRunIndex = useAtomStateValue( currentProfilingRunIndexState, ); const profilingSessionStatus = useAtomStateValue(profilingSessionStatusState); const profilingReport = useMemo( () => computeProfilingReport(profilingSessionDataPoints), [profilingSessionDataPoints], ); return (

Profiling report

Run #{currentProfilingRunIndex} - Status {profilingSessionStatus}
Run name Min Average P50 P80 P90 P95 P99 Max Variance Total {Math.round(profilingReport.total.min * 1000) / 1000}ms {Math.round(profilingReport.total.average * 1000) / 1000}ms {Math.round(profilingReport.total.p50 * 1000) / 1000}ms {Math.round(profilingReport.total.p80 * 1000) / 1000}ms {Math.round(profilingReport.total.p90 * 1000) / 1000}ms {Math.round(profilingReport.total.p95 * 1000) / 1000}ms {Math.round(profilingReport.total.p99 * 1000) / 1000}ms {Math.round(profilingReport.total.max * 1000) / 1000}ms {Math.round(profilingReport.total.variance * 1000000) / 1000000} {Object.entries(profilingReport.runs).map(([runName, report]) => ( {runName} {Math.round(report.min * 1000) / 1000}ms {Math.round(report.average * 1000) / 1000}ms {Math.round(report.p50 * 1000) / 1000}ms {Math.round(report.p80 * 1000) / 1000}ms {Math.round(report.p90 * 1000) / 1000}ms {Math.round(report.p95 * 1000) / 1000}ms {Math.round(report.p99 * 1000) / 1000}ms {Math.round(report.max * 1000) / 1000}ms {Math.round(report.variance * 1000000) / 1000000} ))}
); };