Skip to content

Use a summary table for PR comments #1245

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 1 commit into from
Apr 1, 2022
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
49 changes: 49 additions & 0 deletions collector/src/category.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
use serde::{Deserialize, Serialize};
use std::fmt;

#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, clap::ArgEnum)]
#[serde(rename_all = "kebab-case")]
pub enum Category {
Primary,
Secondary,
Stable,
}

impl Category {
pub fn is_stable(self) -> bool {
self == Category::Stable
}

pub fn is_primary_or_secondary(self) -> bool {
self == Category::Primary || self == Category::Secondary
}

// Within the DB, `Category` is represented in two fields:
// - a `supports_stable` bool,
// - a `category` which is either "primary" or "secondary".
pub fn db_representation(self) -> (bool, String) {
match self {
Category::Primary => (false, "primary".to_string()),
Category::Secondary => (false, "secondary".to_string()),
Category::Stable => (true, "primary".to_string()),
}
}

pub fn from_db_representation(text: &str) -> anyhow::Result<Self> {
match text {
"primary" => Ok(Self::Primary),
"secondary" => Ok(Self::Secondary),
_ => Err(anyhow::anyhow!("Unknown category {text}")),
}
}
}

impl fmt::Display for Category {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Category::Primary => f.write_str("primary"),
Category::Secondary => f.write_str("secondary"),
Category::Stable => f.write_str("stable"),
}
}
}
41 changes: 1 addition & 40 deletions collector/src/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

use crate::{Compiler, Profile, Scenario};
use anyhow::{bail, Context};
use collector::category::Category;
use collector::command_output;
use collector::etw_parser;
use database::{PatchName, QueryLabel};
use futures::stream::FuturesUnordered;
use futures::stream::StreamExt;
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::env;
use std::fmt;
Expand Down Expand Up @@ -107,45 +107,6 @@ fn touch_all(path: &Path) -> anyhow::Result<()> {
Ok(())
}

#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, clap::ArgEnum)]
#[serde(rename_all = "kebab-case")]
pub enum Category {
Primary,
Secondary,
Stable,
}

impl Category {
pub fn is_stable(self) -> bool {
self == Category::Stable
}

pub fn is_primary_or_secondary(self) -> bool {
self == Category::Primary || self == Category::Secondary
}

// Within the DB, `Category` is represented in two fields:
// - a `supports_stable` bool,
// - a `category` which is either "primary" or "secondary".
pub fn db_representation(self) -> (bool, String) {
match self {
Category::Primary => (false, "primary".to_string()),
Category::Secondary => (false, "secondary".to_string()),
Category::Stable => (true, "primary".to_string()),
}
}
}

impl fmt::Display for Category {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Category::Primary => f.write_str("primary"),
Category::Secondary => f.write_str("secondary"),
Category::Stable => f.write_str("stable"),
}
}
}

fn default_runs() -> usize {
3
}
Expand Down
1 change: 1 addition & 0 deletions collector/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use std::fmt;
use std::process::{self, Command};

pub mod api;
pub mod category;
pub mod etw_parser;
mod read2;
pub mod self_profile;
Expand Down
3 changes: 2 additions & 1 deletion collector/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use anyhow::{bail, Context};
use clap::Parser;
use collector::category::Category;
use database::{ArtifactId, Commit};
use log::debug;
use std::collections::HashSet;
Expand All @@ -18,7 +19,7 @@ use tokio::runtime::Runtime;
mod execute;
mod sysroot;

use execute::{BenchProcessor, Benchmark, BenchmarkName, Category, ProfileProcessor, Profiler};
use execute::{BenchProcessor, Benchmark, BenchmarkName, ProfileProcessor, Profiler};
use sysroot::Sysroot;

#[derive(Debug, Copy, Clone)]
Expand Down
Loading