Skip to content

usePerformanceMonitor

@hua-labs/hua/framework
Pro

bash
npm install @hua-labs/hua
tsx
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

fpsThresholdnumber45
sampleSizenumber60
enabledbooleantrue
respectReducedMotionbooleantrue

fpsnumber
frameTimenumber
isLowPerformanceboolean
shouldReduceMotionboolean
droppedFramesnumber
reset() => void
averageFpsnumber
isMonitoringboolean
start() => void
stop() => void