Skip to content

Commit

Permalink
feat: Add totalMs for package cache stats (renovatebot#26610)
Browse files Browse the repository at this point in the history
  • Loading branch information
zharinov authored Jan 12, 2024
1 parent 5210010 commit c8be454
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 2 additions & 0 deletions lib/workers/repository/stats.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,12 +173,14 @@ describe('workers/repository/stats', () => {
"count": 4,
"maxMs": 100,
"medianMs": 20,
"totalMs": 160,
},
"set": {
"avgMs": 70,
"count": 3,
"maxMs": 110,
"medianMs": 80,
"totalMs": 210,
},
}
`);
Expand Down
11 changes: 9 additions & 2 deletions lib/workers/repository/stats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ interface CacheStats {
avgMs?: number;
medianMs?: number;
maxMs?: number;
totalMs?: number;
}

export function printLookupStats(): void {
Expand Down Expand Up @@ -46,8 +47,11 @@ export function printRequestStats(): void {
},
};
if (packageCacheGets.length) {
packageCacheStats.get.totalMs = Math.round(
packageCacheGets.reduce((a, b) => a + b, 0),
);
packageCacheStats.get.avgMs = Math.round(
packageCacheGets.reduce((a, b) => a + b, 0) / packageCacheGets.length,
packageCacheStats.get.totalMs / packageCacheGets.length,
);
if (packageCacheGets.length > 1) {
packageCacheStats.get.medianMs =
Expand All @@ -57,8 +61,11 @@ export function printRequestStats(): void {
}
}
if (packageCacheSets.length) {
packageCacheStats.set.totalMs = Math.round(
packageCacheSets.reduce((a, b) => a + b, 0),
);
packageCacheStats.set.avgMs = Math.round(
packageCacheSets.reduce((a, b) => a + b, 0) / packageCacheSets.length,
packageCacheStats.set.totalMs / packageCacheSets.length,
);
if (packageCacheSets.length > 1) {
packageCacheStats.set.medianMs =
Expand Down

0 comments on commit c8be454

Please sign in to comment.