wip: performance
This commit is contained in:
@@ -6,6 +6,7 @@ import DatePicker from '../pickers/DatePicker';
|
||||
import Dropdown from '../pickers/Dropdown';
|
||||
import TimePicker from '../pickers/TimePicker';
|
||||
import DateTimeLocalPicker from '../pickers/DateTimeLocalPicker';
|
||||
import { FrontendPerformanceMonitor } from '../../../perf/performance';
|
||||
|
||||
interface CreateRefCallback {
|
||||
(ref: React.RefObject<HTMLCanvasElement>): void;
|
||||
@@ -27,6 +28,9 @@ export interface Coordinates {
|
||||
|
||||
const Canvas = ({ width, height, onCreateRef }: CanvasProps) => {
|
||||
|
||||
const performanceMonitor = useRef(new FrontendPerformanceMonitor());
|
||||
console.log('Frontend Performance Report:', performanceMonitor.current.getPerformanceReport());
|
||||
|
||||
const canvasRef = useRef<HTMLCanvasElement>(null);
|
||||
const { socket } = useSocketStore();
|
||||
const { setLastAction, lastAction } = useGlobalInfoStore();
|
||||
@@ -110,6 +114,7 @@ const Canvas = ({ width, height, onCreateRef }: CanvasProps) => {
|
||||
}, [socket]);
|
||||
|
||||
const onMouseEvent = useCallback((event: MouseEvent) => {
|
||||
performanceMonitor.current.measureEventLatency(event);
|
||||
if (socket && canvasRef.current) {
|
||||
// Get the canvas bounding rectangle
|
||||
const rect = canvasRef.current.getBoundingClientRect();
|
||||
@@ -159,6 +164,16 @@ const Canvas = ({ width, height, onCreateRef }: CanvasProps) => {
|
||||
}
|
||||
}, [socket]);
|
||||
|
||||
// performance logging
|
||||
useEffect(() => {
|
||||
const intervalId = setInterval(() => {
|
||||
const report = performanceMonitor.current.getPerformanceReport();
|
||||
console.log('Frontend Performance Report:', report);
|
||||
}, 5000);
|
||||
|
||||
return () => clearInterval(intervalId);
|
||||
}, []);
|
||||
|
||||
const onKeyboardEvent = useCallback((event: KeyboardEvent) => {
|
||||
if (socket) {
|
||||
switch (event.type) {
|
||||
|
||||
Reference in New Issue
Block a user