bash
npm install @hua-labs/huatsx
import { usePerformanceMonitor } from "@hua-labs/hua/framework";tsx
import { usePerformanceMonitor } from "@hua-labs/hua/framework";
const { fps, isLowPerformance, shouldReduceMotion } = usePerformanceMonitor({
fpsThreshold: 45,
sampleSize: 60,
});
// Adapt animations based on performance
const animationDuration = shouldReduceMotion ? 0 : 300;
const enableParticles = !isLowPerformance;
return (
<div style={{ transition: `all ${animationDuration}ms` }}>
{enableParticles && <ParticleEffect />}
<Content />
</div>
);FPS
60
16.67ms
0
- ✓
- ✓
- ✓
- • : ✓
- • requestAnimationFrame: ✓
- • : ✗
- • : 8
| fpsThreshold | number | 45 | |
| sampleSize | number | 60 | |
| enabled | boolean | true | |
| respectReducedMotion | boolean | true |
| fps | number | |
| frameTime | number | |
| isLowPerformance | boolean | |
| shouldReduceMotion | boolean | |
| droppedFrames | number | |
| reset | () => void | |
| averageFps | number | |
| isMonitoring | boolean | |
| start | () => void | |
| stop | () => void |