-
-
Notifications
You must be signed in to change notification settings - Fork 0
Analytics
Arsenal Lab provides comprehensive analytics and performance monitoring capabilities to help you understand and optimize your Bun applications.
- Real-Time Performance Metrics
- Benchmark Analytics
- Analytics Dashboard
- Performance Thresholds
- Data Export
- Configuration
- Troubleshooting
- API Reference
Track frames-per-second in real-time across all components:
import { usePerformanceMonitor } from '@bun/performance-arsenal';
function MyComponent() {
const { fps, memoryUsage } = usePerformanceMonitor();
return (
<div>
<p>FPS: {fps}</p>
<p>Memory: {memoryUsage} MB</p>
</div>
);
}Monitor memory consumption with detailed breakdowns:
- Heap usage
- External memory
- Array buffers
- WebAssembly memory
Automatic hardware profiling:
- CPU cores and architecture
- Available memory
- GPU capabilities
- Network connectivity
Run side-by-side benchmarks between Bun and Node.js:
// Performance comparison results
{
"postMessage": {
"bun": 1250, // operations per second
"node": 890,
"speedup": 1.4
},
"crypto": {
"bun": 4500,
"node": 3200,
"speedup": 1.4
}
}- Benchmark result history
- Performance trend analysis
- Regression detection
- Optimization impact measurement
Real-time performance dashboard showing:
- Current FPS
- Memory usage graphs
- CPU utilization
- Network latency
Track custom performance events:
import { trackBenchmark, trackInteraction } from '@bun/performance-arsenal';
// Track benchmark completion
trackBenchmark('crypto-hash', {
algorithm: 'SHA-256',
inputSize: '1MB',
duration: 45,
throughput: '22.2 MB/s'
});
// Track user interactions
trackInteraction('build-config-change', {
tab: 'optimization',
setting: 'minify',
value: true
});Automatic alerts for performance issues:
- FPS drops below 30
- Memory usage exceeds 500MB
- Long-running operations (>5s)
Intelligent hardware detection and recommendations:
- Minimum requirements checking
- Performance optimization suggestions
- Hardware-specific optimizations
Export analytics data for external analysis:
const analytics = await exportAnalytics();
// Returns structured performance data
{
"session": "2025-01-21T10:30:00Z",
"benchmarks": [...],
"metrics": {
"avgFps": 58.3,
"peakMemory": 234,
"totalBenchmarks": 15
}
}Generate performance reports for documentation:
await exportPerformanceReport('performance-report.csv', {
includeBenchmarks: true,
includeMetrics: true,
dateRange: 'last-7-days'
});Control analytics collection:
// Enable/disable analytics
setAnalyticsEnabled(true);
// Configure data retention
setAnalyticsRetention('30-days');
// Set custom tracking endpoints
setAnalyticsEndpoint('https://analytics.example.com/collect');Respect user privacy preferences:
- Opt-in analytics collection
- Data minimization
- Local storage only (no external tracking)
- Clear data controls
- Use
Bun.gc()for manual garbage collection - Monitor memory leaks with heap snapshots
- Optimize large object allocations
- Leverage Bun's native performance
- Use Web Workers for heavy computations
- Implement efficient algorithms
- Use Bun's fast HTTP client
- Implement proper caching strategies
- Optimize bundle sizes with code splitting
- Chrome DevTools integration
- Firefox performance tools
- Safari Web Inspector support
- macOS: Activity Monitor integration
- Windows: Performance Monitor
- Linux: System monitoring tools
- Low FPS: Check hardware requirements, reduce visual complexity
- High memory usage: Look for memory leaks, optimize data structures
- Slow benchmarks: Ensure clean system state, close background applications
Enable detailed analytics logging:
// Enable debug analytics
setAnalyticsDebug(true);
// View detailed performance logs
console.log(getAnalyticsLogs());const { fps, memoryUsage, analyticsEnabled, toggleAnalytics } = usePerformanceMonitor();-
trackBenchmark(name, data)- Track benchmark results -
trackInteraction(event, data)- Track user interactions -
exportAnalytics()- Export analytics data -
clearAnalytics()- Clear stored analytics data
| Document | Description |
|---|---|
| π Wiki Home | Overview and getting started |
| π§ API Reference | Technical component documentation |
| ποΈ Database Guide | Database integration patterns |
| π SQL Examples | Query patterns and examples |
- π¬ Discussions - Community conversations
- π Issues - Bug reports and feature requests
- π Full Documentation - Complete documentation hub
Built with β€οΈ for the Bun ecosystem β’ Last updated: October 21, 2025