Assistant
18576a6d4a
feat: Add comprehensive performance utilities and monitoring
New utility classes for better performance and resource management:
- **PerformanceOptimizer**: Device-aware optimization adapter
- Adapts frame rates based on available device memory
- Optimized buffer sizes to prevent OOM
- Thread pool sizing based on CPU cores and memory
- Provides recommended cache sizes
- Automatic detection of low-memory devices
- **BufferPool**: Object pooling for byte arrays
- Reuses allocated buffers to reduce GC pressure
- Tracks pool hit/miss statistics
- Concurrent-safe queue implementation
- Configurable pool size limits
- Performance metrics tracking
- **PerformanceMonitor**: Operation metrics tracking
- Records timing for critical operations
- Tracks average, min, max, and total operation times
- Helps identify performance bottlenecks
- Debug logging with frequency control
- Per-operation statistics retrieval
- **ResourceManager**: Lifecycle-aware resource management
- Central registry for application resources
- Ensures proper cleanup of resources
- Prevents resource leaks
- Thread-safe resource tracking
- Comprehensive error handling during cleanup
These utilities enable:
- Better memory management on low-end devices
- Reduced garbage collection pressure
- Performance profiling and optimization
- Resource leak prevention
- Device-adaptive behavior