Skip to content

Commit 2c2a889

Browse files
committed
Simplify querying of statistical descriptions
1 parent bfc2a74 commit 2c2a889

File tree

3 files changed

+18
-27
lines changed

3 files changed

+18
-27
lines changed

database/src/bin/import-sqlite.rs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use database::{CompileBenchmark, Lookup, Pool};
1+
use database::{CompileBenchmark, Pool};
22
use hashbrown::HashMap;
33
use std::collections::HashSet;
44

@@ -45,7 +45,8 @@ async fn main() {
4545
let sqlite_aid = sqlite_conn.artifact_id(&aid).await;
4646
let postgres_aid = postgres_conn.artifact_id(&aid).await;
4747

48-
for &(benchmark, profile, scenario, metric) in sqlite_idx.all_statistic_descriptions() {
48+
for (&(benchmark, profile, scenario, metric), id) in sqlite_idx.all_statistic_descriptions()
49+
{
4950
if benchmarks.insert(benchmark) {
5051
postgres_conn
5152
.record_compile_benchmark(
@@ -56,15 +57,6 @@ async fn main() {
5657
.await;
5758
}
5859

59-
let id = database::DbLabel::StatisticDescription {
60-
benchmark,
61-
profile,
62-
scenario,
63-
metric,
64-
}
65-
.lookup(&sqlite_idx)
66-
.unwrap();
67-
6860
let stat = sqlite_conn
6961
.get_pstats(&[id], &[Some(sqlite_aid)])
7062
.await

database/src/lib.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,8 @@ impl Lookup for ArtifactId {
563563
}
564564
}
565565

566+
pub type StatisticalDescriptionId = u32;
567+
566568
impl Index {
567569
pub async fn load(conn: &mut dyn pool::Connection) -> Index {
568570
conn.load_index().await
@@ -613,8 +615,16 @@ impl Index {
613615
// for it as keeping indices around would be annoying.
614616
pub fn all_statistic_descriptions(
615617
&self,
616-
) -> impl Iterator<Item = &'_ (Benchmark, Profile, Scenario, Metric)> + '_ {
617-
self.pstat_series.map.keys()
618+
) -> impl Iterator<
619+
Item = (
620+
&(Benchmark, Profile, Scenario, Metric),
621+
StatisticalDescriptionId,
622+
),
623+
> + '_ {
624+
self.pstat_series
625+
.map
626+
.iter()
627+
.map(|(test_case, &row_id)| (test_case, row_id))
618628
}
619629

620630
pub fn artifact_id_for_commit(&self, commit: &str) -> Option<ArtifactId> {

site/src/selector.rs

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ impl StatisticSeries {
274274
let index = ctxt.index.load();
275275
let mut statistic_descriptions = index
276276
.all_statistic_descriptions()
277-
.filter(|&&(b, p, s, m)| {
277+
.filter(|(&(b, p, s, m), _)| {
278278
query.benchmark.matches(b)
279279
&& query.profile.matches(p)
280280
&& query.scenario.matches(s)
@@ -284,18 +284,7 @@ impl StatisticSeries {
284284

285285
statistic_descriptions.sort_unstable();
286286

287-
let sids = statistic_descriptions
288-
.iter()
289-
.map(|&&(b, p, s, m)| {
290-
let query = crate::db::DbLabel::StatisticDescription {
291-
benchmark: b,
292-
profile: p,
293-
scenario: s,
294-
metric: m,
295-
};
296-
query.lookup(&index).unwrap()
297-
})
298-
.collect::<Vec<_>>();
287+
let sids: Vec<_> = statistic_descriptions.iter().map(|(_, sid)| *sid).collect();
299288
let aids = artifact_ids
300289
.iter()
301290
.map(|aid| aid.lookup(&index))
@@ -312,7 +301,7 @@ impl StatisticSeries {
312301
.into_iter()
313302
.zip(&statistic_descriptions)
314303
.filter(|(points, _)| points.iter().any(|value| value.is_some()))
315-
.map(|(points, &&(benchmark, profile, scenario, metric))| {
304+
.map(|(points, (&(benchmark, profile, scenario, metric), _))| {
316305
SeriesResponse {
317306
series: StatisticSeries {
318307
artifact_ids: ArtifactIdIter::new(artifact_ids.clone()),

0 commit comments

Comments
 (0)