gristlabs_grist-core/app/server/lib/reportTimeTaken.ts
Dmitry S 00c1a0c688 (core) Log the time taken by decodeActionFromRow() operations.
Summary:
Decoding large actions is a plausible culprit for hogging CPU time for
certain documents. To begin with, log the time taken for this operation,
so that we can tell if it's a problem in practice.

Test Plan: Should not affect any current behaviors

Reviewers: paulfitz

Reviewed By: paulfitz

Differential Revision: https://phab.getgrist.com/D2989
2021-08-20 11:28:33 -04:00

12 lines
315 B
TypeScript

import * as log from 'app/server/lib/log';
export function reportTimeTaken<T>(locationLabel: string, callback: () => T): T {
const start = Date.now();
try {
return callback();
} finally {
const timeTaken = Date.now() - start;
log.debug("Time taken in %s: %s ms", locationLabel, timeTaken);
}
}