⚡ 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}`;
|
const perfLabel = `⚡ ${label}`;
|
||||||
console.time(perfLabel);
|
const startTime = performance.now();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const result = typeof fn === 'function' ? await fn() : fn;
|
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;
|
return result;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.timeEnd(perfLabel);
|
const duration = performance.now() - startTime;
|
||||||
console.error(`${perfLabel} failed:`, error);
|
console.error(`${perfLabel} failed after ${duration.toFixed(3)}ms:`, error);
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user