@@ -29,6 +29,7 @@ export class DeploymentVariableProvider implements VariableProvider {
29
29
}
30
30
31
31
private async getRuleByReference ( reference : string ) {
32
+ const now = performance . now ( ) ;
32
33
const allRelationshipRules =
33
34
await this . workspace . repository . resourceRelationshipRuleRepository . getAll ( ) ;
34
35
const relationshipRule = allRelationshipRules . find (
@@ -54,6 +55,12 @@ export class DeploymentVariableProvider implements VariableProvider {
54
55
const sourceMetadataEquals = allRelationshipRuleSourceMetadataEquals . filter (
55
56
( r ) => r . resourceRelationshipRuleId === relationshipRule . id ,
56
57
) ;
58
+
59
+ const end = performance . now ( ) ;
60
+ const duration = end - now ;
61
+ log . info (
62
+ `Getting relationship rule by reference took ${ duration . toFixed ( 2 ) } ms` ,
63
+ ) ;
57
64
return {
58
65
...relationshipRule ,
59
66
metadataKeysMatch,
@@ -66,6 +73,7 @@ export class DeploymentVariableProvider implements VariableProvider {
66
73
relationshipRule : schema . ResourceRelationshipRule ,
67
74
targetMetadataEqualsRules : schema . ResourceRelationshipRuleTargetMetadataEquals [ ] ,
68
75
) {
76
+ const now = performance . now ( ) ;
69
77
const { resource } = this . releaseTarget ;
70
78
const { targetKind, targetVersion } = relationshipRule ;
71
79
const targetKindSatisfied =
@@ -79,25 +87,34 @@ export class DeploymentVariableProvider implements VariableProvider {
79
87
if ( targetMetadata == null || targetMetadata !== t . value ) return false ;
80
88
}
81
89
90
+ const end = performance . now ( ) ;
91
+ const duration = end - now ;
92
+ log . info ( `Target resource matches rule took ${ duration . toFixed ( 2 ) } ms` ) ;
82
93
return true ;
83
94
}
84
95
85
96
private async getSourceResourceCandidates (
86
97
relationshipRule : schema . ResourceRelationshipRule ,
87
98
) {
99
+ const now = performance . now ( ) ;
88
100
const { sourceKind, sourceVersion } = relationshipRule ;
89
101
const allResources =
90
102
await this . workspace . repository . resourceRepository . getAll ( ) ;
91
- return allResources . filter (
103
+ const resources = allResources . filter (
92
104
( r ) =>
93
105
r . kind === sourceKind &&
94
106
r . version === sourceVersion &&
95
107
r . deletedAt == null ,
96
108
) ;
109
+ const end = performance . now ( ) ;
110
+ const duration = end - now ;
111
+ log . info (
112
+ `Getting source resource candidates took ${ duration . toFixed ( 2 ) } ms` ,
113
+ ) ;
114
+ return resources ;
97
115
}
98
116
99
117
private sourceResourceMatchesRule (
100
- relationshipRule : schema . ResourceRelationshipRule ,
101
118
sourceMetadataEqualsRules : schema . ResourceRelationshipRuleSourceMetadataEquals [ ] ,
102
119
metadataKeysMatchRules : schema . ResourceRelationshipRuleMetadataMatch [ ] ,
103
120
candidate : FullResource ,
@@ -160,17 +177,27 @@ export class DeploymentVariableProvider implements VariableProvider {
160
177
await this . getSourceResourceCandidates ( relationshipRule ) ;
161
178
if ( sourceResourceCandidates . length === 0 ) return defaultValue ;
162
179
180
+ const sourceResourceSearchStart = performance . now ( ) ;
163
181
const sourceResource = sourceResourceCandidates . find ( ( r ) =>
164
182
this . sourceResourceMatchesRule (
165
- relationshipRule ,
166
183
sourceMetadataEquals ,
167
184
metadataKeysMatch ,
168
185
r ,
169
186
) ,
170
187
) ;
188
+ const sourceResourceSearchEnd = performance . now ( ) ;
189
+ const sourceResourceSearchDuration =
190
+ sourceResourceSearchEnd - sourceResourceSearchStart ;
191
+ log . info (
192
+ `Source resource search took ${ sourceResourceSearchDuration . toFixed ( 2 ) } ms` ,
193
+ ) ;
171
194
if ( sourceResource == null ) return defaultValue ;
172
195
196
+ const fullSourceStart = performance . now ( ) ;
173
197
const fullSource = await this . getFullSource ( sourceResource ) ;
198
+ const fullSourceEnd = performance . now ( ) ;
199
+ const fullSourceDuration = fullSourceEnd - fullSourceStart ;
200
+ log . info ( `Full source retrieval took ${ fullSourceDuration . toFixed ( 2 ) } ms` ) ;
174
201
const resolvedPath = _ . get ( fullSource , path , defaultValue ) ;
175
202
return resolvedPath as string | number | boolean | object | null ;
176
203
}
0 commit comments