Skip to content

Commit 1e188b8

Browse files
committed
Post a summary table to PRs after perf. runs
1 parent 10ea9c7 commit 1e188b8

File tree

6 files changed

+463
-108
lines changed

6 files changed

+463
-108
lines changed

collector/src/category.rs

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
use serde::{Deserialize, Serialize};
2+
use std::fmt;
3+
4+
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, clap::ArgEnum)]
5+
#[serde(rename_all = "kebab-case")]
6+
pub enum Category {
7+
Primary,
8+
Secondary,
9+
Stable,
10+
}
11+
12+
impl Category {
13+
pub fn is_stable(self) -> bool {
14+
self == Category::Stable
15+
}
16+
17+
pub fn is_primary_or_secondary(self) -> bool {
18+
self == Category::Primary || self == Category::Secondary
19+
}
20+
21+
// Within the DB, `Category` is represented in two fields:
22+
// - a `supports_stable` bool,
23+
// - a `category` which is either "primary" or "secondary".
24+
pub fn db_representation(self) -> (bool, String) {
25+
match self {
26+
Category::Primary => (false, "primary".to_string()),
27+
Category::Secondary => (false, "secondary".to_string()),
28+
Category::Stable => (true, "primary".to_string()),
29+
}
30+
}
31+
32+
pub fn from_db_representation(text: &str) -> anyhow::Result<Self> {
33+
match text {
34+
"primary" => Ok(Self::Primary),
35+
"secondary" => Ok(Self::Secondary),
36+
_ => Err(anyhow::anyhow!("Unknown category {text}")),
37+
}
38+
}
39+
}
40+
41+
impl fmt::Display for Category {
42+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
43+
match self {
44+
Category::Primary => f.write_str("primary"),
45+
Category::Secondary => f.write_str("secondary"),
46+
Category::Stable => f.write_str("stable"),
47+
}
48+
}
49+
}

collector/src/execute.rs

Lines changed: 1 addition & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
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};
89
use futures::stream::FuturesUnordered;
910
use futures::stream::StreamExt;
10-
use serde::{Deserialize, Serialize};
1111
use std::collections::HashMap;
1212
use std::env;
1313
use std::fmt;
@@ -107,45 +107,6 @@ fn touch_all(path: &Path) -> anyhow::Result<()> {
107107
Ok(())
108108
}
109109

110-
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, clap::ArgEnum)]
111-
#[serde(rename_all = "kebab-case")]
112-
pub enum Category {
113-
Primary,
114-
Secondary,
115-
Stable,
116-
}
117-
118-
impl Category {
119-
pub fn is_stable(self) -> bool {
120-
self == Category::Stable
121-
}
122-
123-
pub fn is_primary_or_secondary(self) -> bool {
124-
self == Category::Primary || self == Category::Secondary
125-
}
126-
127-
// Within the DB, `Category` is represented in two fields:
128-
// - a `supports_stable` bool,
129-
// - a `category` which is either "primary" or "secondary".
130-
pub fn db_representation(self) -> (bool, String) {
131-
match self {
132-
Category::Primary => (false, "primary".to_string()),
133-
Category::Secondary => (false, "secondary".to_string()),
134-
Category::Stable => (true, "primary".to_string()),
135-
}
136-
}
137-
}
138-
139-
impl fmt::Display for Category {
140-
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
141-
match self {
142-
Category::Primary => f.write_str("primary"),
143-
Category::Secondary => f.write_str("secondary"),
144-
Category::Stable => f.write_str("stable"),
145-
}
146-
}
147-
}
148-
149110
fn default_runs() -> usize {
150111
3
151112
}

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)