Skip to content

Commit b5921ea

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

File tree

6 files changed

+450
-107
lines changed

6 files changed

+450
-107
lines changed

collector/src/category.rs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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+
33+
impl fmt::Display for Category {
34+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
35+
match self {
36+
Category::Primary => f.write_str("primary"),
37+
Category::Secondary => f.write_str("secondary"),
38+
Category::Stable => f.write_str("stable"),
39+
}
40+
}
41+
}

collector/src/execute.rs

Lines changed: 1 addition & 39 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,45 +108,6 @@ fn touch_all(path: &Path) -> anyhow::Result<()> {
107108
Ok(())
108109
}
109110

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-
149111
fn default_runs() -> usize {
150112
3
151113
}

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)