File tree Expand file tree Collapse file tree 2 files changed +21
-5
lines changed
Expand file tree Collapse file tree 2 files changed +21
-5
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ import cookieSession from 'cookie-session';
2020import { initRoutes } from './routes' ;
2121import { ensureCachedSheetDataTableExists } from './init-dependencies/google/ensure-cached-sheet-data-table-exists' ;
2222import { loadCachedSheetData } from './load-cached-sheet-data' ;
23+ import { timeAsync } from './util' ;
2324
2425// Dependencies and Config
2526const conf = loadConfig ( ) ;
@@ -95,12 +96,18 @@ void (async () => {
9596 ) ( ) ;
9697
9798 deps . logger . info ( 'Loading cached external events...' ) ;
98- await loadCachedSheetData (
99- deps . getCachedSheetData ,
100- deps . logger ,
101- deps . sharedReadModel . updateState
99+ await timeAsync ( elapsedNs =>
100+ deps . logger . info (
101+ 'Loaded cached external events in %sms' ,
102+ elapsedNs / ( 1000 * 1000 )
103+ )
104+ ) (
105+ loadCachedSheetData (
106+ deps . getCachedSheetData ,
107+ deps . logger ,
108+ deps . sharedReadModel . updateState
109+ )
102110 ) ;
103- deps . logger . info ( 'Cached external events loaded' ) ;
104111 await deps . sharedReadModel . asyncRefresh ( ) ( ) ;
105112 await deps . sharedReadModel . asyncApplyExternalEventSources ( ) ( ) ;
106113
Original file line number Diff line number Diff line change @@ -64,3 +64,12 @@ export const fieldIsUUID =
6464 obj : T
6565 ) : obj is T & { [ P in K ] : tt . UUID } =>
6666 E . isRight ( tt . UUID . decode ( obj [ key ] ) ) ;
67+
68+ export const timeAsync =
69+ ( callback : ( nanoseconds : number ) => void ) => async ( fn : Promise < void > ) => {
70+ const start = process . hrtime . bigint ( ) ;
71+ const result = await fn ;
72+ // Realistically we aren't going to be have elapsed periods big enough that this conversion back to number is problematic.
73+ callback ( Number ( process . hrtime . bigint ( ) - start ) ) ;
74+ return result ;
75+ } ;
You can’t perform that action at this time.
0 commit comments