Comprehensive browser hardware profiling for AI-powered applications
Hardware Capability Profiler is a production-ready TypeScript library for comprehensive browser hardware detection and capability assessment. Perfect for applications that need to adapt their behavior based on available hardware, especially AI-powered applications using local models, WebGPU, or advanced browser features.
- GPU Detection: WebGPU, WebGL2, VRAM estimation, vendor/renderer identification
- CPU Detection: Core count, architecture, SIMD, WebAssembly support
- Memory Detection: RAM, JS heap, device memory API
- Storage Detection: IndexedDB, storage quota, persistence type
- Network Detection: Connection type, speed, RTT, data saver mode
- Display Detection: Resolution, pixel ratio, color depth, orientation
- Browser Detection: Browser name, version, OS, platform, touch support
- Feature Detection: 12+ web platform APIs (Web Workers, WebRTC, etc.)
- JEPA Scoring: Specialized scoring (0-100) for AI workload capability
- Performance Classification: 4-tier system (low-end, mid-range, high-end, extreme)
- Capability Evaluation: Feature availability recommendations
- Zero Dependencies: Completely standalone, no framework coupling
npm install @superinstance/hardware-capability-profilerimport { HardwareProfiler } from '@superinstance/hardware-capability-profiler';
// Create profiler instance
const profiler = new HardwareProfiler();
// Detect hardware capabilities
const profile = await profiler.detect();
console.log(`Performance Score: ${profile.performanceScore}/100`);
console.log(`CPU Cores: ${profile.cpu.cores}`);
console.log(`GPU: ${profile.gpu.renderer}`);
console.log(`RAM: ${profile.memory.totalGB}GB`);
// Adaptive behavior based on performance
if (profile.performanceClass === 'premium') {
// Enable all features including local AI models
} else if (profile.performanceClass === 'low') {
// Use lightweight alternatives and API-based AI
}import { calculateJEPAScore } from '@superinstance/hardware-capability-profiler';
const score = calculateJEPAScore(profile);
console.log(`JEPA Score: ${score.score}/100`);
console.log(`Tier: ${score.tier}`);
console.log(`Tiny-JEPA: ${score.jepa.tinyJEPA ? 'β
' : 'β'}`);
console.log(`JEPA-Large: ${score.jepa.largeJEPA ? 'β
' : 'β'}`);
console.log(`Real-time Transcription: ${score.jepa.realtimeTranscription ? 'β
' : 'β'}`);
// View recommendations
score.recommendations.forEach(rec => console.log(`β’ ${rec}`));import { evaluateCapabilities } from '@superinstance/hardware-capability-profiler';
const assessment = evaluateCapabilities(profile);
// Check if local AI is viable
if (assessment.canUseLocalAI) {
console.log('β
Can use local AI models');
}
// Get recommended configuration
const config = assessment.recommendedConfiguration;
console.log(`AI Provider: ${config.aiProvider}`);
console.log(`Transcription Model: ${config.transcriptionModel}`);
console.log(`Max Batch Size: ${config.maxBatchSize}`);
// Check specific features
const aiFeatures = assessment.features.filter(f => f.id.startsWith('ai.'));
aiFeatures.forEach(feature => {
if (feature.available) {
console.log(`β
${feature.name} (${feature.expectedPerformance} performance)`);
} else {
console.log(`β ${feature.name}: ${feature.reason}`);
}
});The JEPA (Joint Embedding Predictive Architecture) scoring system evaluates hardware specifically for AI workloads:
- GPU (up to 40 points): Tensor cores, VRAM, compute capability
- RAM (up to 30 points): Total memory, available memory
- CPU (up to 20 points): Cores, SIMD, threads
- Storage (up to 10 points): Speed, available space
| Tier | Score Range | Typical Hardware | JEPA Capabilities |
|---|---|---|---|
| Low-end | 0-20 | Integrated GPU, <8GB RAM | API streaming only |
| Mid-range | 20-50 | RTX 4050, 8-16GB RAM | Tiny-JEPA, basic transcription |
| High-end | 50-80 | RTX 4070, 16GB+ RAM | JEPA-Large, multimodal |
| Extreme | 80-100 | RTX 5090, 32GB+ RAM | JEPA-XL, multi-model |
- Tiny-JEPA: Score 30+, 4GB+ VRAM, 8GB+ RAM
- JEPA-Large: Score 50+, 8GB+ VRAM, 16GB+ RAM
- JEPA-XL: Score 80+, 16GB+ VRAM, 32GB+ RAM
- Real-time Transcription: Score 40+, 6GB+ VRAM
- Multimodal: Score 60+, Tensor cores required
import { getPerformanceScore } from '@superinstance/hardware-capability-profiler';
const score = await getPerformanceScore();
let aiModel: string;
if (score >= 80) {
aiModel = 'gpt-4-turbo'; // Premium
} else if (score >= 60) {
aiModel = 'gpt-4'; // High
} else if (score >= 40) {
aiModel = 'gpt-3.5-turbo'; // Medium
} else {
aiModel = 'gpt-3.5-turbo-16k'; // Low
}import { evaluateCapabilities } from '@superinstance/hardware-capability-profiler';
const assessment = evaluateCapabilities(profile);
// Use feature flags to enable/disable features
const featureFlags = assessment.featureFlags;
if (featureFlags['ai.local_models']) {
enableLocalAI();
}
if (featureFlags['ui.virtual_scrolling']) {
enableVirtualScrolling();
}
if (featureFlags['media.image_analysis']) {
enableImageAnalysis();
}import { getHardwareInfo } from '@superinstance/hardware-capability-profiler';
const { profile } = await getHardwareInfo();
if (profile.browser.os === 'macOS') {
// Enable Metal optimizations
if (profile.gpu.renderer?.includes('Apple M')) {
enableMetalPerformanceShaders();
}
} else if (profile.browser.os === 'Windows') {
// Enable DirectML or CUDA
if (profile.gpu.renderer?.includes('NVIDIA')) {
enableCUDA();
}
}Main detector class for hardware profiling.
Methods:
getHardwareInfo(options?: DetectionOptions, useCache?: boolean): Promise<DetectionResult>getPerformanceScore(): Promise<number>detectCapabilities(): Promise<FeatureSupport>clearCache(): void
getHardwareInfo(options?: DetectionOptions): Promise<DetectionResult>getPerformanceScore(): Promise<number>detectCapabilities(): Promise<FeatureSupport>clearHardwareCache(): voidgetDetector(): HardwareDetector
calculateJEPAScore(profile: HardwareProfile): HardwareScoreResultgetJEPARequirements(): Record<string, { minScore: number; description: string }>
evaluateCapabilities(profile: HardwareProfile): CapabilityAssessmentgetFeaturesByCategory(assessment: CapabilityAssessment, category: string): FeatureAvailability[]getOptimizedFeatureSet(assessment: CapabilityAssessment, targetPerformance: PerformanceLevel): string[]
See docs/API.md for complete type definitions.
| Feature | Chrome | Firefox | Safari | Edge |
|---|---|---|---|---|
| CPU Cores | β | β | β | β |
| Device Memory | β (Android) | β | β | β |
| WebGL 1.0 | β | β | β | β |
| WebGL 2.0 | β | β | β | β |
| WebGPU | β (113+) | β | ||
| Network Info | β (Android) | β | β | β |
| Storage API | β | β |
interface DetectionOptions {
detailedGPU?: boolean; // Enable detailed GPU detection (slower)
checkQuota?: boolean; // Check storage quota (slower)
detectWebGL?: boolean; // Detect WebGL capabilities (recommended)
timeout?: number; // Timeout in ms (default: 5000)
}const result = await getHardwareInfo({
detailedGPU: true, // Get detailed GPU info
checkQuota: true, // Check storage quota
detectWebGL: true, // Detect WebGL
timeout: 10000, // 10 second timeout
});See the examples/ directory for complete working examples:
- Basic Detection - Simple hardware detection
- JEPA Scoring - Calculate JEPA capability scores
- Feature Detection - Check specific capabilities
- Platform Optimization - Platform-specific code paths
Hardware Capability Profiler uses a modular architecture:
- Detector Layer: Hardware detection and profiling
- Scoring Layer: Performance scoring and tier classification
- Capability Layer: Feature evaluation and recommendations
- Type Layer: Comprehensive TypeScript definitions
See docs/ARCHITECTURE.md for detailed architecture documentation.
- First Detection: ~50-150ms
- Cached Detection: <1ms
- Fast Mode: ~20-50ms (without GPU/WebGL details)
- Memory Overhead: <5KB for cached profile
# Run tests
npm test
# Run tests in watch mode
npm run test:watch
# Run tests with coverage
npm run test:coverage
# Type checking
npm run type-checkContributions are welcome! Please see CONTRIBUTING.md for guidelines.
MIT License - see LICENSE for details.
Built as part of the PersonalLog project, extracted as an independent tool for the community.
Made with β€οΈ by SuperInstance