Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 53 additions & 8 deletions site/frontend/src/pages/status/collector.vue
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
<script setup lang="tsx">
import {h, ref, Ref} from "vue";
import {parseISO, differenceInHours} from "date-fns";
import {formatISODate} from "../../utils/formatting";
import {
parseISO,
differenceInHours,
differenceInSeconds,
format,
} from "date-fns";
import {
formatISODate,
formatSecondsAsDuration,
parseDateIsoStringOrNull,
} from "../../utils/formatting";
import {
CollectorConfig,
BenchmarkJobStatus,
isJobComplete,
BenchmarkJob,
BenchmarkJobKind,
} from "./data";
import CommitSha from "./commit-sha.vue";

Expand Down Expand Up @@ -45,6 +55,12 @@ function formatJobStatus(status: BenchmarkJobStatus): string {
return "Unknown";
}
}
function formatJobKind(kind: BenchmarkJobKind): string {
if (kind === "compiletime") {
return "compile";
}
return kind;
}

function ActiveStatus({collector}: {collector: CollectorConfig}) {
const now = new Date();
Expand Down Expand Up @@ -101,6 +117,35 @@ function formatProfile(job: BenchmarkJob): string {
return "";
}
}
function timeSince(timestamp: string): string {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a site/frontend/src/utils/formatting.ts file, I think this should live there

const date = parseDateIsoStringOrNull(timestamp);
if (date === null) {
return "";
}
const now = new Date();
const diffSeconds = differenceInSeconds(now, date);
return formatSecondsAsDuration(diffSeconds);
}

// Takes a date like `2025-09-10T08:22:47.161348Z` and shows just the time
// portion (`08:22:47`).
function formatTime(dateString: string | null): string {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think this should also live in; site/frontend/src/utils/formatting.ts

const date = parseDateIsoStringOrNull(dateString);
if (date === null) {
return "";
}
return format(date, "HH:mm:ss");
}

function jobDuration(job: BenchmarkJob): string {
if (!isJobComplete(job)) {
return "";
}
const start = parseDateIsoStringOrNull(job.startedAt);
const end = parseDateIsoStringOrNull(job.completedAt);
const diff = differenceInSeconds(end, start);
return `Job took ${formatSecondsAsDuration(diff)}`;
}
</script>

<template>
Expand Down Expand Up @@ -182,18 +227,18 @@ function formatProfile(job: BenchmarkJob): string {
<template v-for="job in collector.jobs">
<tr v-if="ACTIVE_FILTERS[job.status]">
<td>
<CommitSha :tag="job.requestTag"></CommitSha>
<CommitSha :tag="job.requestTag" :truncate="true"></CommitSha>
</td>
<td>
{{ formatJobStatus(job.status) }}
</td>
<td>
{{ formatISODate(job.startedAt) }}
<td :title="`Started ${timeSince(job.startedAt)} ago`">
{{ formatTime(job.startedAt) }}
</td>
<td>
{{ formatISODate(job.completedAt) }}
<td :title="jobDuration(job)">
{{ formatTime(job.completedAt) }}
</td>
<td>{{ job.kind }}</td>
<td>{{ formatJobKind(job.kind) }}</td>
<td>{{ formatBackend(job) }}</td>
<td>
{{ formatProfile(job) }}
Expand Down
42 changes: 22 additions & 20 deletions site/frontend/src/pages/status/page.vue
Original file line number Diff line number Diff line change
Expand Up @@ -122,32 +122,34 @@ function ExpectedCurrentRequestCompletion() {

const now = new Date();
const diffSeconds = differenceInSeconds(estimatedCompleted, now);
const prettyDisplay = formatSecondsAsDuration(diffSeconds);

let expectedEnd: string;
if (diffSeconds >= 0) {
let remainingSeconds = formatSecondsAsDuration(diffSeconds);
expectedEnd = `expected to end in approximately ${remainingSeconds}`;
} else {
expectedEnd = "is running longer than expected";
}

let kind = "PR";
let link;
if (req.requestType === "Release") {
return (
<span>
Current Benchmark for{" "}
<strong>
<CommitSha tag={req.tag}></CommitSha>
</strong>{" "}
expected to end in approximately {prettyDisplay}
</span>
);
link = <CommitSha tag={req.tag}></CommitSha>;
kind = "";
} else {
const url = `https://github.com/rust-lang/rust/pull/${req.pr}`;
return (
<span>
Current Benchmark for PR{" "}
<strong>
<a href={url} target="_blank">
#{req.pr}
</a>{" "}
</strong>
expected to end in approximately {prettyDisplay}
</span>
link = (
<a href={url} target="_blank">
#{req.pr}
</a>
);
}

return (
<span>
Current benchmark for {kind} <strong>{link}</strong> {expectedEnd}.
</span>
);
}

function PullRequestLink({request}: {request: BenchmarkRequest}) {
Expand Down
Loading