Skip to content

Commit ad55bf5

Browse files
committed
Show average request duration per collector in the statu spage
1 parent e9f4f7d commit ad55bf5

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

site/frontend/src/pages/status/collector.vue

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,18 @@ function jobDuration(job: BenchmarkJob): string {
146146
const diff = differenceInSeconds(end, start);
147147
return `Job took ${formatSecondsAsDuration(diff)}`;
148148
}
149+
150+
function averageCollectorDuration(collector: CollectorConfig): string {
151+
if (collector.pastRequestDurations.length === 0) {
152+
return "Unknown";
153+
}
154+
const durationSum = collector.pastRequestDurations.reduce(
155+
(acc, req) => acc + req.job_duration_s,
156+
0
157+
);
158+
const averageDuration = durationSum / collector.pastRequestDurations.length;
159+
return formatSecondsAsDuration(averageDuration);
160+
}
149161
</script>
150162

151163
<template>
@@ -194,6 +206,15 @@ function jobDuration(job: BenchmarkJob): string {
194206
></span
195207
>
196208
</div>
209+
<div
210+
class="collector-meta"
211+
title="Average duration to compute all jobs for the past few benchmark requests."
212+
>
213+
<span class="collector-meta-name">
214+
<strong>Average duration:</strong>
215+
</span>
216+
<span>{{ averageCollectorDuration(collector) }}</span>
217+
</div>
197218
<button @click="toggleShowJobs" class="show-jobs">
198219
<template v-if="showJobs">Hide jobs</template>
199220
<template v-else>Show jobs</template>
@@ -273,7 +294,7 @@ $sm-radius: 8px;
273294
padding: 16px;
274295
display: flex;
275296
box-shadow: 0 1px 2px #0006;
276-
margin: 0px 8px 8px 0px;
297+
margin: 0 8px 8px 0;
277298
}
278299
.collector-name {
279300
font-size: 1.5em;
@@ -290,7 +311,7 @@ $sm-radius: 8px;
290311
291312
.collector-meta-name {
292313
display: block;
293-
min-width: 125px;
314+
min-width: 140px;
294315
}
295316
296317
.collector-left-divider {
@@ -302,7 +323,7 @@ $sm-radius: 8px;
302323
}
303324
304325
.collector-sm-padding-left-right {
305-
padding: 0px $sm-padding;
326+
padding: 0 $sm-padding;
306327
}
307328
.collector-sm-padding-left {
308329
padding-left: $sm-padding;

0 commit comments

Comments
 (0)