Files
twenty/front/src/modules/ui/utilities/debug/components/TimingProfiler.tsx
Félix Malfait aeccc87ac5 Yarn upgrade (#2749)
* yarn upgrade front and docs

* upgrade yarn server

* Revert change not needed
2023-11-28 16:48:02 +01:00

45 lines
892 B
TypeScript

import { Profiler } from 'react';
import { Interaction } from 'scheduler/tracing';
import { logDebug } from '~/utils/logDebug';
type TimingProfilerProps = {
id: string;
children: React.ReactNode;
};
export const TimingProfiler = ({ id, children }: TimingProfilerProps) => {
const handleRender = (
id: string,
phase: 'mount' | 'update' | 'nested-update',
actualDuration: number,
baseDuration: number,
startTime: number,
commitTime: number,
interactions: Set<Interaction>,
) => {
logDebug(
'TimingProfiler',
JSON.stringify(
{
id,
phase,
actualDuration,
baseDuration,
startTime,
commitTime,
interactions,
},
null,
2,
),
);
};
return (
<Profiler id={id} onRender={handleRender}>
{children}
</Profiler>
);
};