Download script.js from saif-1307/pc-performance-harmony-analyzer: direct link, hf CLI and curl.
- Browser
- Download file 12.7 kB
-
https://huggingface.co/spaces/saif-1307/pc-performance-harmony-analyzer/resolve/main/script.js
- Command line
-
hf download hf://spaces/saif-1307/pc-performance-harmony-analyzer/script.js
-
curl -L -o script.js https://huggingface.co/spaces/saif-1307/pc-performance-harmony-analyzer/resolve/main/script.js
12.7 kB
| // Sample data - in a real app, this would come from an API | |
| const cpuData = [ | |
| // Intel 13th Gen | |
| { id: 1, name: "Intel Core i9-13900K", cores: 24, threads: 32, baseClock: 3.0, boostClock: 5.8, tdp: 125 }, | |
| { id: 2, name: "Intel Core i7-13700K", cores: 16, threads: 24, baseClock: 3.4, boostClock: 5.4, tdp: 125 }, | |
| { id: 3, name: "Intel Core i5-13600K", cores: 14, threads: 20, baseClock: 3.5, boostClock: 5.1, tdp: 125 }, | |
| { id: 4, name: "Intel Core i9-13900", cores: 24, threads: 32, baseClock: 2.0, boostClock: 5.6, tdp: 65 }, | |
| { id: 5, name: "Intel Core i7-13700", cores: 16, threads: 24, baseClock: 2.1, boostClock: 5.2, tdp: 65 }, | |
| { id: 6, name: "Intel Core i5-13600", cores: 14, threads: 20, baseClock: 2.7, boostClock: 5.0, tdp: 65 }, | |
| // Intel 12th Gen | |
| { id: 7, name: "Intel Core i9-12900K", cores: 16, threads: 24, baseClock: 3.2, boostClock: 5.2, tdp: 125 }, | |
| { id: 8, name: "Intel Core i7-12700K", cores: 12, threads: 20, baseClock: 3.6, boostClock: 5.0, tdp: 125 }, | |
| { id: 9, name: "Intel Core i5-12600K", cores: 10, threads: 16, baseClock: 3.7, boostClock: 4.9, tdp: 125 }, | |
| { id: 10, name: "Intel Core i9-12900", cores: 16, threads: 24, baseClock: 2.4, boostClock: 5.1, tdp: 65 }, | |
| { id: 11, name: "Intel Core i7-12700", cores: 12, threads: 20, baseClock: 2.1, boostClock: 4.9, tdp: 65 }, | |
| { id: 12, name: "Intel Core i5-12600", cores: 6, threads: 12, baseClock: 3.3, boostClock: 4.8, tdp: 65 }, | |
| // AMD Ryzen 7000 Series | |
| { id: 13, name: "AMD Ryzen 9 7950X", cores: 16, threads: 32, baseClock: 4.5, boostClock: 5.7, tdp: 170 }, | |
| { id: 14, name: "AMD Ryzen 9 7900X", cores: 12, threads: 24, baseClock: 4.7, boostClock: 5.6, tdp: 170 }, | |
| { id: 15, name: "AMD Ryzen 7 7800X3D", cores: 8, threads: 16, baseClock: 4.2, boostClock: 5.0, tdp: 120 }, | |
| { id: 16, name: "AMD Ryzen 7 7700X", cores: 8, threads: 16, baseClock: 4.5, boostClock: 5.4, tdp: 105 }, | |
| { id: 17, name: "AMD Ryzen 5 7600X", cores: 6, threads: 12, baseClock: 4.7, boostClock: 5.3, tdp: 105 }, | |
| // AMD Ryzen 5000 Series | |
| { id: 18, name: "AMD Ryzen 9 5950X", cores: 16, threads: 32, baseClock: 3.4, boostClock: 4.9, tdp: 105 }, | |
| { id: 19, name: "AMD Ryzen 9 5900X", cores: 12, threads: 24, baseClock: 3.7, boostClock: 4.8, tdp: 105 }, | |
| { id: 20, name: "AMD Ryzen 7 5800X3D", cores: 8, threads: 16, baseClock: 3.4, boostClock: 4.5, tdp: 105 }, | |
| { id: 21, name: "AMD Ryzen 7 5800X", cores: 8, threads: 16, baseClock: 3.8, boostClock: 4.7, tdp: 105 }, | |
| { id: 22, name: "AMD Ryzen 5 5600X", cores: 6, threads: 12, baseClock: 3.7, boostClock: 4.6, tdp: 65 }, | |
| // AMD Ryzen 3000 Series | |
| { id: 23, name: "AMD Ryzen 9 3950X", cores: 16, threads: 32, baseClock: 3.5, boostClock: 4.7, tdp: 105 }, | |
| { id: 24, name: "AMD Ryzen 9 3900X", cores: 12, threads: 24, baseClock: 3.8, boostClock: 4.6, tdp: 105 }, | |
| { id: 25, name: "AMD Ryzen 7 3800X", cores: 8, threads: 16, baseClock: 3.9, boostClock: 4.5, tdp: 105 }, | |
| { id: 26, name: "AMD Ryzen 7 3700X", cores: 8, threads: 16, baseClock: 3.6, boostClock: 4.4, tdp: 65 }, | |
| { id: 27, name: "AMD Ryzen 5 3600X", cores: 6, threads: 12, baseClock: 3.8, boostClock: 4.4, tdp: 95 }, | |
| { id: 28, name: "AMD Ryzen 5 3600", cores: 6, threads: 12, baseClock: 3.6, boostClock: 4.2, tdp: 65 }, | |
| // Budget Options | |
| { id: 29, name: "Intel Core i3-13100", cores: 4, threads: 8, baseClock: 3.4, boostClock: 4.5, tdp: 60 }, | |
| { id: 30, name: "Intel Core i3-12100", cores: 4, threads: 8, baseClock: 3.3, boostClock: 4.3, tdp: 60 }, | |
| { id: 31, name: "AMD Ryzen 5 5500", cores: 6, threads: 12, baseClock: 3.6, boostClock: 4.2, tdp: 65 }, | |
| { id: 32, name: "AMD Ryzen 3 3300X", cores: 4, threads: 8, baseClock: 3.8, boostClock: 4.3, tdp: 65 } | |
| ]; | |
| const gpuData = [ | |
| { id: 1, name: "NVIDIA RTX 4090", vram: 24, baseClock: 2235, boostClock: 2520, tdp: 450 }, | |
| { id: 2, name: "AMD RX 7900 XTX", vram: 24, baseClock: 1900, boostClock: 2500, tdp: 355 }, | |
| { id: 3, name: "NVIDIA RTX 4080", vram: 16, baseClock: 2205, boostClock: 2505, tdp: 320 }, | |
| { id: 4, name: "AMD RX 7900 XT", vram: 20, baseClock: 1500, boostClock: 2400, tdp: 300 }, | |
| { id: 5, name: "NVIDIA RTX 4070 Ti", vram: 12, baseClock: 2310, boostClock: 2610, tdp: 285 }, | |
| { id: 6, name: "AMD RX 7800 XT", vram: 16, baseClock: 1800, boostClock: 2430, tdp: 263 }, | |
| { id: 7, name: "NVIDIA RTX 3090 Ti", vram: 24, baseClock: 1560, boostClock: 1860, tdp: 450 }, | |
| { id: 8, name: "AMD RX 6950 XT", vram: 16, baseClock: 1890, boostClock: 2310, tdp: 335 }, | |
| { id: 9, name: "NVIDIA RTX 3080 Ti", vram: 12, baseClock: 1365, boostClock: 1665, tdp: 350 }, | |
| { id: 10, name: "AMD RX 6800 XT", vram: 16, baseClock: 1825, boostClock: 2250, tdp: 300 }, | |
| ]; | |
| // DOM elements | |
| const cpuList = document.getElementById('cpu-list'); | |
| const gpuList = document.getElementById('gpu-list'); | |
| const cpuSearch = document.getElementById('cpu-search'); | |
| const gpuSearch = document.getElementById('gpu-search'); | |
| const calculateBtn = document.getElementById('calculate-btn'); | |
| const resultContainer = document.getElementById('result-container'); | |
| const selectedCpu = document.getElementById('selected-cpu'); | |
| const selectedGpu = document.getElementById('selected-gpu'); | |
| const bottleneckPercentage = document.getElementById('bottleneck-percentage'); | |
| const bottleneckMeter = document.getElementById('bottleneck-meter'); | |
| const recommendations = document.getElementById('recommendations'); | |
| const resolutionSelect = document.getElementById('resolution-select'); | |
| // Selected components | |
| let selectedCPU = null; | |
| let selectedGPU = null; | |
| // Initialize the component lists | |
| function initComponentLists() { | |
| renderCPUList(cpuData); | |
| renderGPUList(gpuData); | |
| } | |
| // Render CPU list | |
| function renderCPUList(cpus) { | |
| cpuList.innerHTML = ''; | |
| cpus.forEach(cpu => { | |
| const li = document.createElement('li'); | |
| li.className = 'px-4 py-3 hover:bg-gray-50 cursor-pointer'; | |
| li.dataset.id = cpu.id; | |
| li.innerHTML = ` | |
| <div class="font-medium">${cpu.name}</div> | |
| <div class="text-sm text-gray-500">${cpu.cores}C/${cpu.threads}T | ${cpu.baseClock}-${cpu.boostClock}GHz | ${cpu.tdp}W</div> | |
| `; | |
| li.addEventListener('click', () => selectComponent(cpu, 'cpu')); | |
| cpuList.appendChild(li); | |
| }); | |
| } | |
| // Render GPU list | |
| function renderGPUList(gpus) { | |
| gpuList.innerHTML = ''; | |
| gpus.forEach(gpu => { | |
| const li = document.createElement('li'); | |
| li.className = 'px-4 py-3 hover:bg-gray-50 cursor-pointer'; | |
| li.dataset.id = gpu.id; | |
| li.innerHTML = ` | |
| <div class="font-medium">${gpu.name}</div> | |
| <div class="text-sm text-gray-500">${gpu.vram}GB | ${gpu.baseClock}-${gpu.boostClock}MHz | ${gpu.tdp}W</div> | |
| `; | |
| li.addEventListener('click', () => selectComponent(gpu, 'gpu')); | |
| gpuList.appendChild(li); | |
| }); | |
| } | |
| // Select component | |
| function selectComponent(component, type) { | |
| // Remove previous selection | |
| const previousSelected = document.querySelector(`.selected-component[data-type="${type}"]`); | |
| if (previousSelected) { | |
| previousSelected.classList.remove('selected-component'); | |
| } | |
| // Add new selection | |
| const newSelected = document.querySelector(`[data-id="${component.id}"]`); | |
| if (newSelected) { | |
| newSelected.classList.add('selected-component'); | |
| newSelected.setAttribute('data-type', type); | |
| } | |
| // Update selected component | |
| if (type === 'cpu') { | |
| selectedCPU = component; | |
| selectedCpu.textContent = component.name; | |
| } else { | |
| selectedGPU = component; | |
| selectedGpu.textContent = component.name; | |
| } | |
| // Enable calculate button if both components are selected | |
| if (selectedCPU && selectedGPU) { | |
| calculateBtn.disabled = false; | |
| } | |
| } | |
| // Calculate bottleneck | |
| function calculateBottleneck() { | |
| if (!selectedCPU || !selectedGPU) return; | |
| // Show results container | |
| resultContainer.classList.remove('hidden'); | |
| // Simple bottleneck calculation (this would be more complex in reality) | |
| // This is a simplified example - real calculation would consider many more factors | |
| const resolution = parseInt(resolutionSelect.value); | |
| let cpuScore = (selectedCPU.cores * selectedCPU.threads * selectedCPU.boostClock) / 100; | |
| let gpuScore = (selectedGPU.vram * selectedGPU.boostClock) / 100; | |
| // Adjust scores based on resolution (higher resolutions are more GPU-bound) | |
| if (resolution === 1080) { | |
| cpuScore *= 1.2; // More CPU impact at 1080p | |
| } else if (resolution === 1440) { | |
| cpuScore *= 1.0; | |
| gpuScore *= 1.0; | |
| } else { | |
| gpuScore *= 1.2; // More GPU impact at 4K | |
| } | |
| const bottleneck = Math.abs((cpuScore - gpuScore) / Math.max(cpuScore, gpuScore) * 100); | |
| const roundedBottleneck = Math.round(bottleneck); | |
| // Update UI | |
| bottleneckPercentage.textContent = `${roundedBottleneck}%`; | |
| const meterValue = 100 - roundedBottleneck; | |
| bottleneckMeter.setAttribute('stroke-dasharray', `${meterValue}, 100`); | |
| // Set meter color based on severity | |
| if (roundedBottleneck < 10) { | |
| bottleneckMeter.setAttribute('stroke', '#10b981'); // Green | |
| } else if (roundedBottleneck < 20) { | |
| bottleneckMeter.setAttribute('stroke', '#3b82f6'); // Blue | |
| } else if (roundedBottleneck < 30) { | |
| bottleneckMeter.setAttribute('stroke', '#f59e0b'); // Yellow | |
| } else { | |
| bottleneckMeter.setAttribute('stroke', '#ef4444'); // Red | |
| } | |
| // Generate recommendations | |
| generateRecommendations(roundedBottleneck, cpuScore > gpuScore); | |
| } | |
| // Generate recommendations | |
| function generateRecommendations(bottleneck, isCpuBottleneck) { | |
| recommendations.innerHTML = ''; | |
| if (bottleneck < 10) { | |
| const li = document.createElement('li'); | |
| li.className = 'flex items-start'; | |
| li.innerHTML = ` | |
| <i data-feather="check-circle" class="text-green-500 mr-2 mt-0.5"></i> | |
| <span>Excellent balance! Your components are well-matched.</span> | |
| `; | |
| recommendations.appendChild(li); | |
| } else { | |
| const severity = bottleneck < 20 ? 'slight' : bottleneck < 30 ? 'moderate' : 'severe'; | |
| const component = isCpuBottleneck ? 'CPU' : 'GPU'; | |
| const li1 = document.createElement('li'); | |
| li1.className = 'flex items-start'; | |
| li1.innerHTML = ` | |
| <i data-feather="alert-circle" class="text-yellow-500 mr-2 mt-0.5"></i> | |
| <span>${severity.charAt(0).toUpperCase() + severity.slice(1)} ${component} bottleneck detected (${bottleneck}%).</span> | |
| `; | |
| recommendations.appendChild(li1); | |
| const li2 = document.createElement('li'); | |
| li2.className = 'flex items-start'; | |
| li2.innerHTML = ` | |
| <i data-feather="arrow-up" class="text-blue-500 mr-2 mt-0.5"></i> | |
| <span>Consider upgrading your ${component} for better performance.</span> | |
| `; | |
| recommendations.appendChild(li2); | |
| if (isCpuBottleneck) { | |
| const li3 = document.createElement('li'); | |
| li3.className = 'flex items-start'; | |
| li3.innerHTML = ` | |
| <i data-feather="monitor" class="text-purple-500 mr-2 mt-0.5"></i> | |
| <span>Higher resolutions will reduce CPU bottleneck.</span> | |
| `; | |
| recommendations.appendChild(li3); | |
| } else { | |
| const li3 = document.createElement('li'); | |
| li3.className = 'flex items-start'; | |
| li3.innerHTML = ` | |
| <i data-feather="cpu" class="text-purple-500 mr-2 mt-0.5"></i> | |
| <span>Your CPU has headroom for a more powerful GPU.</span> | |
| `; | |
| recommendations.appendChild(li3); | |
| } | |
| } | |
| feather.replace(); | |
| } | |
| // Search functionality | |
| cpuSearch.addEventListener('input', (e) => { | |
| const searchTerm = e.target.value.toLowerCase(); | |
| const filteredCPUs = cpuData.filter(cpu => | |
| cpu.name.toLowerCase().includes(searchTerm) | |
| ); | |
| renderCPUList(filteredCPUs); | |
| }); | |
| gpuSearch.addEventListener('input', (e) => { | |
| const searchTerm = e.target.value.toLowerCase(); | |
| const filteredGPUs = gpuData.filter(gpu => | |
| gpu.name.toLowerCase().includes(searchTerm) | |
| ); | |
| renderGPUList(filteredGPUs); | |
| }); | |
| // Calculate button click | |
| calculateBtn.addEventListener('click', calculateBottleneck); | |
| // Resolution change | |
| resolutionSelect.addEventListener('change', () => { | |
| if (selectedCPU && selectedGPU) { | |
| calculateBottleneck(); | |
| } | |
| }); | |
| // Initialize | |
| document.addEventListener('DOMContentLoaded', () => { | |
| initComponentLists(); | |
| calculateBtn.disabled = true; | |
| }); |