Skip to content

Commit bbd0705

Browse files
committed
Use summary table in GitHub listener
1 parent 123c4bc commit bbd0705

File tree

6 files changed

+240
-150
lines changed

6 files changed

+240
-150
lines changed

collector/src/category.rs

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
use serde::{Deserialize, Serialize};
2+
use std::fmt;
3+
4+
#[derive(Debug, Clone, Copy, Serialize, Deserialize, clap::ArgEnum)]
5+
#[serde(rename_all = "kebab-case")]
6+
pub enum Category {
7+
Primary,
8+
Secondary,
9+
// FIXME: this should disappear after the 2022 benchmark overhaul is
10+
// complete.
11+
PrimaryAndStable,
12+
Stable,
13+
}
14+
15+
impl Category {
16+
pub fn from_db_representation(value: &str) -> anyhow::Result<Category> {
17+
match value {
18+
"primary" => Ok(Self::Primary),
19+
"secondary" => Ok(Self::Secondary),
20+
_ => Err(anyhow::anyhow!("Invalid category {value}")),
21+
}
22+
}
23+
24+
pub fn has_stable(&self) -> bool {
25+
match self {
26+
Category::Primary | Category::Secondary => false,
27+
Category::PrimaryAndStable | Category::Stable => true,
28+
}
29+
}
30+
31+
pub fn is_primary_or_secondary(&self) -> bool {
32+
match self {
33+
Category::Primary | Category::Secondary | Category::PrimaryAndStable => true,
34+
Category::Stable => false,
35+
}
36+
}
37+
38+
// Within the DB, `Category` is represented in two fields:
39+
// - a `supports_stable` bool,
40+
// - a `category` which is either "primary" or "secondary".
41+
pub fn db_representation(&self) -> (bool, String) {
42+
match self {
43+
Category::Primary => (false, "primary".to_string()),
44+
Category::Secondary => (false, "secondary".to_string()),
45+
// These two have the same DB representation, even though they are
46+
// treated differently when choosing which benchmarks to run.
47+
Category::PrimaryAndStable | Category::Stable => (true, "primary".to_string()),
48+
}
49+
}
50+
}
51+
52+
impl fmt::Display for Category {
53+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
54+
match self {
55+
Category::Primary => f.write_str("primary"),
56+
Category::Secondary => f.write_str("secondary"),
57+
Category::PrimaryAndStable => f.write_str("primary-and-stable"),
58+
Category::Stable => f.write_str("stable"),
59+
}
60+
}
61+
}

collector/src/execute.rs

Lines changed: 1 addition & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
33
use crate::{Compiler, Profile, Scenario};
44
use anyhow::{bail, Context};
5+
use collector::category::Category;
56
use collector::command_output;
67
use collector::etw_parser;
78
use database::{PatchName, QueryLabel};
@@ -107,57 +108,6 @@ fn touch_all(path: &Path) -> anyhow::Result<()> {
107108
Ok(())
108109
}
109110

110-
#[derive(Debug, Clone, Copy, Serialize, Deserialize, clap::ArgEnum)]
111-
#[serde(rename_all = "kebab-case")]
112-
pub enum Category {
113-
Primary,
114-
Secondary,
115-
// FIXME: this should disappear after the 2022 benchmark overhaul is
116-
// complete.
117-
PrimaryAndStable,
118-
Stable,
119-
}
120-
121-
impl Category {
122-
pub fn has_stable(&self) -> bool {
123-
match self {
124-
Category::Primary | Category::Secondary => false,
125-
Category::PrimaryAndStable | Category::Stable => true,
126-
}
127-
}
128-
129-
pub fn is_primary_or_secondary(&self) -> bool {
130-
match self {
131-
Category::Primary | Category::Secondary | Category::PrimaryAndStable => true,
132-
Category::Stable => false,
133-
}
134-
}
135-
136-
// Within the DB, `Category` is represented in two fields:
137-
// - a `supports_stable` bool,
138-
// - a `category` which is either "primary" or "secondary".
139-
pub fn db_representation(&self) -> (bool, String) {
140-
match self {
141-
Category::Primary => (false, "primary".to_string()),
142-
Category::Secondary => (false, "secondary".to_string()),
143-
// These two have the same DB representation, even though they are
144-
// treated differently when choosing which benchmarks to run.
145-
Category::PrimaryAndStable | Category::Stable => (true, "primary".to_string()),
146-
}
147-
}
148-
}
149-
150-
impl fmt::Display for Category {
151-
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
152-
match self {
153-
Category::Primary => f.write_str("primary"),
154-
Category::Secondary => f.write_str("secondary"),
155-
Category::PrimaryAndStable => f.write_str("primary-and-stable"),
156-
Category::Stable => f.write_str("stable"),
157-
}
158-
}
159-
}
160-
161111
fn default_runs() -> usize {
162112
3
163113
}

collector/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use std::fmt;
66
use std::process::{self, Command};
77

88
pub mod api;
9+
pub mod category;
910
pub mod etw_parser;
1011
mod read2;
1112
pub mod self_profile;

collector/src/main.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
use anyhow::{bail, Context};
44
use clap::Parser;
5+
use collector::category::Category;
56
use database::{ArtifactId, Commit};
67
use log::debug;
78
use std::collections::HashSet;
@@ -18,7 +19,7 @@ use tokio::runtime::Runtime;
1819
mod execute;
1920
mod sysroot;
2021

21-
use execute::{BenchProcessor, Benchmark, BenchmarkName, Category, ProfileProcessor, Profiler};
22+
use execute::{BenchProcessor, Benchmark, BenchmarkName, ProfileProcessor, Profiler};
2223
use sysroot::Sysroot;
2324

2425
#[derive(Debug, Copy, Clone)]

0 commit comments

Comments
 (0)