(function() {
if (window.stressTestInitialized) return;
window.stressTestInitialized = true;
class StressTest {
constructor() {
this.createPanel();
this.setupShortcut();
}
createPanel() {
const panel = document.createElement('div');
panel.style.cssText = `
position: fixed;
bottom: 20px;
right: 20px;
width: 350px;
background: #1a1a1a;
border: 2px solid #ff0000;
border-radius: 8px;
padding: 15px;
z-index: 99999;
font-family: monospace;
color: #00ff00;
display: none;
max-height: 500px;
overflow-y: auto;
`;
panel.innerHTML = `
STRESS TEST
Ready...
`;
document.body.appendChild(panel);
this.panel = panel;
this.output = panel.querySelector('#stress-output');
window.stressTest = this;
}
setupShortcut() {
document.addEventListener('keydown', (e) => {
if (e.ctrlKey && e.shiftKey && e.code === 'KeyS') {
this.panel.style.display = this.panel.style.display === 'none' ? 'block' : 'none';
}
});
}
log(msg) {
this.output.innerHTML += `${msg}
`;
this.output.scrollTop = this.output.scrollHeight;
}
async memoryTest() {
this.output.innerHTML = '🔥 Memory Test Starting...';
try {
const arrays = [];
for (let i = 0; i < 500; i++) {
arrays.push(new Uint8Array(1024 * 1024));
if (i % 50 === 0) this.log(`✓ ${i}MB`);
await new Promise(r => setTimeout(r, 10));
}
this.log('✅ Test complete: 500MB');
} catch(e) {
this.log(`❌ ${e.message}`);
}
}
async cpuTest() {
this.output.innerHTML = '🔥 CPU Test Starting...';
const start = performance.now();
let r = 0;
for (let i = 0; i < 300000000; i++) {
r += Math.sqrt(i) * Math.sin(i);
}
this.log(`✅ Complete: ${Math.round(performance.now() - start)}ms`);
}
async domTest() {
this.output.innerHTML = '🔥 DOM Test Starting...';
const c = document.createElement('div');
c.style.display = 'none';
for (let i = 0; i < 50000; i++) {
const e = document.createElement('div');
e.textContent = `Node ${i}`;
c.appendChild(e);
if (i % 5000 === 0) this.log(`✓ ${i} nodes`);
}
document.body.appendChild(c);
this.log('✅ 50k nodes created');
setTimeout(() => c.remove(), 3000);
}
async runAll() {
await this.memoryTest();
this.log('---');
await this.cpuTest();
this.log('---');
await this.domTest();
}
}
new StressTest();
})();