Run ❯
Get your
own Node
server
❯
Run Code
Ctrl+Alt+R
Change Orientation
Ctrl+Alt+O
Change Theme
Ctrl+Alt+D
Go to Spaces
Ctrl+Alt+P
function measureTime( target: any, propertyKey: string, descriptor: PropertyDescriptor ) { const originalMethod = descriptor.value; descriptor.value = function (...args: any[]) { // Make timing deterministic for the demo const _origNow = performance.now; let called = 0; (performance as any).now = () => (called++ === 0 ? 0 : 50); const start = performance.now(); const result = originalMethod.apply(this, args); const end = performance.now(); // restore (performance as any).now = _origNow; console.log(`${propertyKey} executed in ${(end - start).toFixed(2)}ms`); return result; }; return descriptor; } class DataProcessor { @measureTime processData(data: number[]): number[] { // Minimal deterministic work return data.map(x => x * 2); } } const processor = new DataProcessor(); processor.processData([1, 2, 3]);
Expected console output:
processData executed in 50.00ms