Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit cd1af30

Browse files
committed
Separate compile and runtime metrics
This makes the select box in compare/runtime page more precise, and it also fills it with relevant data if only runtime entries are present in the DB (this is only relevant for local execution of the site).
1 parent 10901b1 commit cd1af30

File tree

9 files changed

+40
-16
lines changed

9 files changed

+40
-16
lines changed

database/src/lib.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ impl Index {
594594
// millions of queries and labels and iterating all of them is eventually
595595
// going to be impractical. But for now it performs quite well, so we'll go
596596
// for it as keeping indices around would be annoying.
597-
pub fn metrics(&self) -> Vec<String> {
597+
pub fn compile_metrics(&self) -> Vec<String> {
598598
self.pstat_series
599599
.map
600600
.keys()
@@ -605,6 +605,17 @@ impl Index {
605605
.collect()
606606
}
607607

608+
pub fn runtime_metrics(&self) -> Vec<String> {
609+
self.runtime_pstat_series
610+
.map
611+
.keys()
612+
.map(|(_, metric)| metric)
613+
.collect::<std::collections::HashSet<_>>()
614+
.into_iter()
615+
.map(|s| s.to_string())
616+
.collect()
617+
}
618+
608619
// FIXME: in theory this won't scale indefinitely as there's potentially
609620
// millions of queries and labels and iterating all of them is eventually
610621
// going to be impractical. But for now it performs quite well, so we'll go

site/frontend/src/api.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ import {getJson} from "./utils/requests";
22
import {INFO_URL} from "./urls";
33

44
export interface BenchmarkInfo {
5-
// Known statistic values from the DB
6-
stats: [string];
5+
// Known compile metrics from the DB
6+
compile_metrics: [string];
7+
// Known runtime metrics from the DB
8+
runtime_metrics: [string];
79
// Last loaded run date
810
as_of: string | null;
911
}

site/frontend/src/pages/compare/compile/compile-page.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ const filteredSummary = computed(() => computeSummary(comparisons.value));
189189
<MetricSelector
190190
:quick-links="importantCompileMetrics"
191191
:selected-metric="selector.stat"
192-
:benchmark-info="benchmarkInfo"
192+
:metrics="benchmarkInfo.compile_metrics"
193193
/>
194194
<Filters
195195
:defaultFilter="defaultCompileFilter"

site/frontend/src/pages/compare/header/data-selector.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,10 @@ const opened = ref(false);
7979
"
8080
>
8181
<select class="stats" ref="statRef">
82-
<option v-for="value in props.info.stats" :value="value">
82+
<option
83+
v-for="value in props.info.compile_metrics"
84+
:value="value"
85+
>
8386
{{ value }}
8487
</option>
8588
</select>

site/frontend/src/pages/compare/metric-selector.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {MetricDescription} from "./metrics";
99
const props = defineProps<{
1010
quickLinks: MetricDescription[];
1111
selectedMetric: string;
12-
benchmarkInfo: BenchmarkInfo;
12+
metrics: string[];
1313
}>();
1414
1515
function navigateToMetric(metric: string) {
@@ -37,9 +37,9 @@ function changeMetric(e: Event) {
3737
metric.label
3838
}}</a>
3939
</div>
40-
<select class="stats" @change="changeMetric">
40+
<select class="stats" @change="changeMetric" v-if="metrics.length > 0">
4141
<option
42-
v-for="value in benchmarkInfo.stats"
42+
v-for="value in metrics"
4343
:value="value"
4444
:selected="value === selectedMetric"
4545
>

site/frontend/src/pages/compare/runtime/runtime-page.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,9 @@ const filteredSummary = computed(() => computeSummary(comparisons.value));
9292

9393
<template>
9494
<MetricSelector
95-
:selected-metric="selector.stat"
96-
:benchmark-info="benchmarkInfo"
9795
:quick-links="importantRuntimeMetrics"
96+
:selected-metric="selector.stat"
97+
:metrics="benchmarkInfo.runtime_metrics"
9898
/>
9999
<Filters
100100
:defaultFilter="defaultRuntimeFilter"

site/frontend/src/pages/graphs/data-selector.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ function submitSettings() {
5353
<option value="percentrelative">Percent Delta from Previous</option>
5454
</select>
5555
<select ref="statRef">
56-
<option v-for="value in info.stats" :value="value">
56+
<option v-for="value in info.compile_metrics" :value="value">
5757
{{ value }}
5858
</option></select
5959
>&nbsp;<a href="#" @click.prevent="submitSettings">Submit</a>

site/src/api.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,11 @@ pub mod info {
1414

1515
#[derive(Debug, Clone, PartialEq, Serialize)]
1616
pub struct Response {
17-
/// Sorted list of statistic names known
18-
pub stats: Vec<String>,
17+
/// Sorted list of known compile metrics
18+
pub compile_metrics: Vec<String>,
19+
20+
/// Sorted list of known runtime metrics
21+
pub runtime_metrics: Vec<String>,
1922

2023
/// Chronologically last loaded run date.
2124
pub as_of: Option<Date>,

site/src/request_handlers.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,15 @@ use crate::api::{info, ServerResult};
2121
use crate::load::SiteCtxt;
2222

2323
pub fn handle_info(ctxt: &SiteCtxt) -> info::Response {
24-
let mut metrics = ctxt.index.load().metrics();
25-
metrics.sort();
24+
let mut compile_metrics = ctxt.index.load().compile_metrics();
25+
compile_metrics.sort();
26+
27+
let mut runtime_metrics = ctxt.index.load().runtime_metrics();
28+
runtime_metrics.sort();
29+
2630
info::Response {
27-
stats: metrics,
31+
compile_metrics,
32+
runtime_metrics,
2833
as_of: ctxt.index.load().commits().last().map(|d| d.date),
2934
}
3035
}

0 commit comments

Comments
 (0)