@@ -7,20 +7,25 @@ export const getPublishersForFeed = async (
7
7
cluster : Cluster ,
8
8
) => {
9
9
"use cache" ;
10
+ const start = performance . now ( ) ;
10
11
const data = await clients [ cluster ] . getData ( ) ;
11
12
const result : Record < string , string [ ] > = { } ;
12
13
for ( const key of data . productPrice . keys ( ) ) {
13
14
const price = data . productPrice . get ( key ) ;
14
15
result [ key ] = price ?. priceComponents . map ( ( { publisher } ) => publisher . toBase58 ( ) ) ?? [ ] ;
15
16
}
17
+ const end = performance . now ( ) ;
18
+ // eslint-disable-next-line no-console, @typescript-eslint/restrict-template-expressions
19
+ console . log ( `getPublishersForFeed: ${ end - start } ms` ) ;
16
20
return result ;
17
21
} ;
18
22
19
23
const getFeeds = async ( cluster : Cluster ) => {
20
24
"use cache" ;
25
+ const start = performance . now ( ) ;
21
26
const data = await clients [ cluster ] . getData ( ) ;
22
27
23
- return superjson . stringify ( priceFeedsSchema . parse ( data . symbols . filter (
28
+ const result = superjson . stringify ( priceFeedsSchema . parse ( data . symbols . filter (
24
29
( symbol ) =>
25
30
data . productFromSymbol . get ( symbol ) ?. display_symbol !== undefined ,
26
31
) . map ( ( symbol ) => ( {
@@ -33,14 +38,22 @@ const getFeeds = async (cluster: Cluster) => {
33
38
} ) ) ?? [ ] ,
34
39
} ,
35
40
} ) ) ) )
41
+ const end = performance . now ( ) ;
42
+ // eslint-disable-next-line no-console, @typescript-eslint/restrict-template-expressions
43
+ console . log ( `getFeeds: ${ end - start } ms` ) ;
44
+ return result ;
36
45
}
37
46
38
47
export const getFeedsForPublisherCached = async (
39
48
cluster : Cluster ,
40
49
publisher : string ,
41
50
) => {
51
+ const start = performance . now ( ) ;
42
52
const rawFeeds = await getFeeds ( cluster ) ;
43
53
const feeds = superjson . parse < z . infer < typeof priceFeedsSchema > > ( rawFeeds ) ;
54
+ const end = performance . now ( ) ;
55
+ // eslint-disable-next-line no-console, @typescript-eslint/restrict-template-expressions
56
+ console . log ( `getFeedsForPublisherCached: ${ end - start } ms` ) ;
44
57
return priceFeedsSchema . parse ( feeds . filter ( ( { price } ) =>
45
58
price . priceComponents . some (
46
59
( component ) => component . publisher . toString ( ) === publisher ,
@@ -50,11 +63,19 @@ export const getFeedsForPublisherCached = async (
50
63
51
64
export const getFeedsCached = async ( cluster : Cluster ) => {
52
65
"use cache" ;
66
+ const start = performance . now ( ) ;
53
67
const rawFeeds = await getFeeds ( cluster ) ;
68
+ const end = performance . now ( ) ;
69
+ // eslint-disable-next-line no-console, @typescript-eslint/restrict-template-expressions
70
+ console . log ( `getFeedsCached: ${ end - start } ms` ) ;
54
71
return superjson . parse < z . infer < typeof priceFeedsSchema > > ( rawFeeds ) ;
55
72
} ;
56
73
57
74
export const getPublishersForFeedCached = async ( cluster : Cluster , symbol : string ) => {
75
+ const start = performance . now ( ) ;
58
76
const data = await getPublishersForFeed ( cluster ) ;
77
+ const end = performance . now ( ) ;
78
+ // eslint-disable-next-line no-console, @typescript-eslint/restrict-template-expressions
79
+ console . log ( `getPublishersForFeedCached: ${ end - start } ms` ) ;
59
80
return data [ symbol ] ;
60
81
} ;
0 commit comments