Skip to content

Data extrapolation/intrapolation #253

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jul 14, 2018
Merged
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
94 changes: 77 additions & 17 deletions collector/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use std::hash;
use std::str::FromStr;
use std::path::{Path, PathBuf};
use std::process::{self, Stdio};
use std::borrow::Cow;

use chrono::{DateTime, Datelike, Duration, TimeZone, Utc};
use chrono::naive::NaiveDate;
Expand Down Expand Up @@ -61,13 +62,27 @@ impl Ord for Commit {
}
}

#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq, Hash)]
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct Patch {
index: usize,
pub name: String,
path: PathBuf,
}

impl PartialEq for Patch {
fn eq(&self, other: &Self) -> bool {
self.name == other.name
}
}

impl Eq for Patch {}

impl hash::Hash for Patch {
fn hash<H: hash::Hasher>(&self, h: &mut H) {
self.name.hash(h);
}
}

impl Patch {
pub fn new(path: PathBuf) -> Self {
assert!(path.is_file());
Expand Down Expand Up @@ -138,14 +153,14 @@ impl BenchmarkState {
}
}

pub fn name(&self) -> String {
pub fn name(&self) -> Cow<'static, str> {
match *self {
BenchmarkState::Clean => format!("clean"),
BenchmarkState::Nll => format!("nll"),
BenchmarkState::IncrementalStart => format!("baseline incremental"),
BenchmarkState::IncrementalClean => format!("clean incremental"),
BenchmarkState::Clean => "clean".into(),
BenchmarkState::Nll => "nll".into(),
BenchmarkState::IncrementalStart => "baseline incremental".into(),
BenchmarkState::IncrementalClean => "clean incremental".into(),
BenchmarkState::IncrementalPatched(ref patch) => {
format!("patched incremental: {}", patch.name)
format!("patched incremental: {}", patch.name).into()
}
}
}
Expand Down Expand Up @@ -176,7 +191,7 @@ pub struct Stat {
pub cnt: f64,
}

#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)]
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct Run {
pub stats: Vec<Stat>,
#[serde(default)]
Expand All @@ -185,6 +200,48 @@ pub struct Run {
pub state: BenchmarkState,
}

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct RunId {
check: bool,
release: bool,
state: BenchmarkState,
}

impl RunId {
pub fn name(&self) -> String {
self.to_string()
}
}

impl fmt::Display for RunId {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let opt = if self.release {
"-opt"
} else if self.check {
"-check"
} else {
""
};
write!(f, "{}{}", self.state.name(), opt)
}
}

impl PartialEq for Run {
fn eq(&self, other: &Self) -> bool {
self.release == other.release &&
self.check == other.check &&
self.state == other.state
}
}

impl PartialEq<RunId> for Run {
fn eq(&self, other: &RunId) -> bool {
self.release == other.release &&
self.check == other.check &&
self.state == other.state
}
}

impl Run {
pub fn is_clean(&self) -> bool {
self.state == BenchmarkState::Clean
Expand All @@ -209,15 +266,18 @@ impl Run {
false
}

pub fn id(&self) -> RunId {
let state = self.state.clone();
let state = state.erase_path();
RunId {
check: self.check,
release: self.release,
state: state,
}
}

pub fn name(&self) -> String {
let opt = if self.release {
"-opt"
} else if self.check {
"-check"
} else {
""
};
self.state.name() + opt
self.id().name()
}

pub fn get_stat(&self, stat: &str) -> Option<f64> {
Expand All @@ -243,7 +303,7 @@ pub struct CommitData {
#[derive(Debug, Copy, Clone, PartialEq, PartialOrd, Serialize, Deserialize)]
pub struct DeltaTime(#[serde(with = "round_float")] pub f64);

#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)]
#[derive(Debug, Hash, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)]
pub struct Date(pub DateTime<Utc>);

#[derive(Debug, Clone, PartialEq, Eq)]
Expand Down
7 changes: 4 additions & 3 deletions site/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ pub mod data {
use server::DateData;
use collector::Bound;

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Request {
pub start: Bound,
pub end: Bound,
Expand All @@ -101,7 +101,7 @@ pub mod data {
}

/// List of DateData's from oldest to newest
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Response(pub Vec<DateData>);
}

Expand All @@ -126,6 +126,7 @@ pub mod graph {
pub percent: f32,
pub y: f32,
pub x: u64,
pub color: String,
}

#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)]
Expand All @@ -148,7 +149,7 @@ pub mod days {
pub stat: String,
}

#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Response {
pub a: DateData,
pub b: DateData,
Expand Down
Loading