Skip to content

Commit 55b84f4

Browse files
Merge pull request #898 from rylev/renames
Some Refactorings
2 parents 2132441 + d9fd96f commit 55b84f4

File tree

12 files changed

+338
-361
lines changed

12 files changed

+338
-361
lines changed

collector/src/lib.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,15 @@ pub use self_profile::{QueryData, SelfProfile};
1616
#[derive(Debug, Copy, Clone, PartialEq, PartialOrd, Deserialize)]
1717
pub struct DeltaTime(#[serde(with = "round_float")] pub f64);
1818

19-
/// The bound of a range changes in codebase
19+
/// The bound for finding an artifact
2020
///
21-
/// This can either be the upper or lower bound
21+
/// This can either be the upper or lower bound.
22+
/// In the case of commits or tags this is an exact bound, but for dates
23+
/// it's a best effort (i.e., if the bound is a date but there are no artifacts
24+
/// for that date, we'll find the artifact that most closely matches).
2225
#[derive(Debug, Clone, PartialEq, Eq)]
2326
pub enum Bound {
24-
/// An unverified git commit (in sha form)
27+
/// An unverified git commit (in sha form) or a tag of a commit (e.g., "1.53.0")
2528
Commit(String),
2629
/// A date in time
2730
Date(NaiveDate),
@@ -30,7 +33,7 @@ pub enum Bound {
3033
}
3134

3235
impl Bound {
33-
/// Tests whether self bounds the commit to the left
36+
/// Tests whether `self` matches commit when searching from the left
3437
pub fn left_match(&self, commit: &Commit) -> bool {
3538
match self {
3639
Bound::Commit(sha) => commit.sha == **sha,
@@ -42,7 +45,7 @@ impl Bound {
4245
}
4346
}
4447

45-
/// Tests whether self bounds the commit to the right
48+
/// Tests whether `self` matches commit when searching from the right
4649
pub fn right_match(&self, commit: &Commit) -> bool {
4750
match self {
4851
Bound::Commit(sha) => commit.sha == **sha,

database/src/lib.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -450,9 +450,11 @@ pub struct LabelId(pub u8, pub u32);
450450
#[derive(Serialize, Deserialize, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
451451
pub struct ArtifactIdNumber(pub u32);
452452

453-
/// Id lookups for various things
453+
/// Cached Id lookups for many database tables.
454454
///
455-
/// This is a quick way to find what the database id for something
455+
/// This is a quick way to find what the database id for something.
456+
/// Essentially duplicates of the various database tables (artifacts,
457+
/// error_series, pstat_series, etc.) so that we can avoid a network round-trip.
456458
#[derive(Debug, Clone, PartialEq, Eq, Default)]
457459
pub struct Index {
458460
/// Id look for a commit

site/src/api.rs

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,3 @@
1-
// Copyright 2016 The rustc-perf Project Developers. See the COPYRIGHT
2-
// file at the top-level directory.
3-
//
4-
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
5-
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
6-
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
7-
// option. This file may not be copied, modified, or distributed
8-
// except according to those terms.
9-
101
//! Each API endpoint has its own module. The modules contain Request and/or
112
//! Response structs; these contain the specifications for how to interact
123
//! with the API.
@@ -80,7 +71,7 @@ pub struct CommitResponse {
8071
}
8172

8273
pub mod data {
83-
use crate::comparison::DateData;
74+
use crate::comparison::ArtifactData;
8475
use collector::Bound;
8576
use serde::{Deserialize, Serialize};
8677

@@ -95,7 +86,7 @@ pub mod data {
9586

9687
/// List of DateData's from oldest to newest
9788
#[derive(Debug, Clone, Serialize)]
98-
pub struct Response(pub Vec<DateData>);
89+
pub struct Response(pub Vec<ArtifactData>);
9990
}
10091

10192
pub mod graph {
@@ -165,16 +156,16 @@ pub mod bootstrap {
165156
}
166157
}
167158

168-
pub mod days {
169-
use crate::comparison::DateData;
159+
pub mod comparison {
170160
use collector::Bound;
161+
use database::Date;
171162
use serde::{Deserialize, Serialize};
163+
use std::collections::HashMap;
172164

173165
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)]
174166
pub struct Request {
175167
pub start: Bound,
176168
pub end: Bound,
177-
178169
pub stat: String,
179170
}
180171

@@ -183,8 +174,8 @@ pub mod days {
183174
/// The names for the previous artifact before `a`, if any.
184175
pub prev: Option<String>,
185176

186-
pub a: DateData,
187-
pub b: DateData,
177+
pub a: ArtifactData,
178+
pub b: ArtifactData,
188179

189180
/// The names for the next artifact after `b`, if any.
190181
pub next: Option<String>,
@@ -193,6 +184,16 @@ pub mod days {
193184
/// `b`).
194185
pub is_contiguous: bool,
195186
}
187+
188+
/// A serializable wrapper for `comparison::ArtifactData`.
189+
#[derive(Debug, Clone, Serialize)]
190+
pub struct ArtifactData {
191+
pub commit: String,
192+
pub date: Option<Date>,
193+
pub pr: Option<u32>,
194+
pub data: HashMap<String, Vec<(String, f64)>>,
195+
pub bootstrap: HashMap<String, u64>,
196+
}
196197
}
197198

198199
pub mod status {

0 commit comments

Comments
 (0)