Files
docmost/apps/server/src/common/helpers/log-timing.ts
T
Philipinho 147f734c97 POC
2026-05-12 22:56:22 +01:00

22 lines
559 B
TypeScript

export function LogTiming() {
return function (
target: any,
propertyKey: string,
descriptor: PropertyDescriptor,
) {
const original = descriptor.value;
descriptor.value = async function (...args: any[]) {
const start = performance.now();
try {
return await original.apply(this, args);
} finally {
const ms = performance.now() - start;
console.log(
`[perm-timing] ${target.constructor.name}.${propertyKey} ${ms.toFixed(2)}ms`,
);
}
};
return descriptor;
};
}