⚡ Improve performance monitoring by replacing console.time with performance.now for more precise timing
This commit is contained in:
@@ -26,15 +26,16 @@ export async function perfMonitor(label, fn) {
|
||||
}
|
||||
|
||||
const perfLabel = `⚡ ${label}`;
|
||||
console.time(perfLabel);
|
||||
const startTime = performance.now();
|
||||
|
||||
try {
|
||||
const result = typeof fn === 'function' ? await fn() : fn;
|
||||
console.timeEnd(perfLabel);
|
||||
const duration = performance.now() - startTime;
|
||||
console.debug(`${perfLabel}: ${duration.toFixed(3)}ms`);
|
||||
return result;
|
||||
} catch (error) {
|
||||
console.timeEnd(perfLabel);
|
||||
console.error(`${perfLabel} failed:`, error);
|
||||
const duration = performance.now() - startTime;
|
||||
console.error(`${perfLabel} failed after ${duration.toFixed(3)}ms:`, error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user