Skip to content

Commit 2484444

Browse files
authored
Merge pull request #1332 from rylev/metric
Prefer the term metric over stat
2 parents 898c46f + 99d3677 commit 2484444

File tree

3 files changed

+34
-34
lines changed

3 files changed

+34
-34
lines changed

site/src/api.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ pub mod bootstrap {
130130
}
131131

132132
pub mod comparison {
133-
use crate::comparison::Stat;
133+
use crate::comparison::Metric;
134134
use collector::Bound;
135135
use database::{BenchmarkData, Date};
136136
use serde::{Deserialize, Serialize};
@@ -140,7 +140,7 @@ pub mod comparison {
140140
pub struct Request {
141141
pub start: Bound,
142142
pub end: Bound,
143-
pub stat: Stat,
143+
pub stat: Metric,
144144
}
145145

146146
#[derive(Debug, Clone, Serialize, Deserialize)]

site/src/comparison.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ pub async fn handle_triage(
4545
let mut before = start.clone();
4646

4747
let mut num_comparisons = 0;
48-
let stat = Stat::Instructions;
48+
let metric = Metric::Instructions;
4949
let benchmark_map = ctxt.get_benchmark_category_map().await;
5050
loop {
5151
let comparison =
52-
match compare_given_commits(before, next.clone(), stat, ctxt, &master_commits)
52+
match compare_given_commits(before, next.clone(), metric, ctxt, &master_commits)
5353
.await
5454
.map_err(|e| format!("error comparing commits: {}", e))?
5555
{
@@ -86,7 +86,7 @@ pub async fn handle_triage(
8686

8787
// Summarize the entire triage from start commit to end commit
8888
let summary =
89-
match compare_given_commits(start.clone(), end.clone(), stat, ctxt, master_commits)
89+
match compare_given_commits(start.clone(), end.clone(), metric, ctxt, master_commits)
9090
.await
9191
.map_err(|e| format!("error comparing beginning and ending commits: {}", e))?
9292
{
@@ -181,7 +181,7 @@ async fn populate_report(
181181
}
182182

183183
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)]
184-
pub enum Stat {
184+
pub enum Metric {
185185
#[serde(rename = "instructions:u")]
186186
Instructions,
187187
#[serde(rename = "cycles:u")]
@@ -198,7 +198,7 @@ pub enum Stat {
198198
CpuClock,
199199
}
200200

201-
impl Stat {
201+
impl Metric {
202202
pub fn as_str(&self) -> &'static str {
203203
match self {
204204
Self::Instructions => "instructions:u",
@@ -586,19 +586,19 @@ pub fn write_summary_table_footer(result: &mut String) {
586586
pub async fn compare(
587587
start: Bound,
588588
end: Bound,
589-
stat: Stat,
589+
metric: Metric,
590590
ctxt: &SiteCtxt,
591591
) -> Result<Option<ArtifactComparison>, BoxedError> {
592592
let master_commits = &ctxt.get_master_commits().commits;
593593

594-
compare_given_commits(start, end, stat, ctxt, master_commits).await
594+
compare_given_commits(start, end, metric, ctxt, master_commits).await
595595
}
596596

597-
/// Compare two bounds on a given stat
597+
/// Compare two bounds on a given metric
598598
async fn compare_given_commits(
599599
start: Bound,
600600
end: Bound,
601-
stat: Stat,
601+
metric: Metric,
602602
ctxt: &SiteCtxt,
603603
master_commits: &[collector::MasterCommit],
604604
) -> Result<Option<ArtifactComparison>, BoxedError> {
@@ -612,12 +612,12 @@ async fn compare_given_commits(
612612
};
613613
let aids = Arc::new(vec![a.clone(), b.clone()]);
614614

615-
// get all crates, cache, and profile combinations for the given stat
615+
// get all crates, cache, and profile combinations for the given metric
616616
let query = selector::Query::new()
617617
.set::<String>(Tag::Benchmark, selector::Selector::All)
618618
.set::<String>(Tag::Scenario, selector::Selector::All)
619619
.set::<String>(Tag::Profile, selector::Selector::All)
620-
.set(Tag::Metric, selector::Selector::One(stat.as_str()));
620+
.set(Tag::Metric, selector::Selector::One(metric.as_str()));
621621

622622
// `responses` contains series iterators. The first element in the iterator is the data
623623
// for `a` and the second is the data for `b`
@@ -628,7 +628,7 @@ async fn compare_given_commits(
628628
let statistics_for_b = statistics_from_series(&mut responses);
629629

630630
let mut historical_data =
631-
HistoricalDataMap::calculate(ctxt, a.clone(), master_commits, stat).await?;
631+
HistoricalDataMap::calculate(ctxt, a.clone(), master_commits, metric).await?;
632632
let comparisons = statistics_for_a
633633
.into_iter()
634634
.filter_map(|(test_case, a)| {
@@ -864,7 +864,7 @@ impl HistoricalDataMap {
864864
ctxt: &SiteCtxt,
865865
from: ArtifactId,
866866
master_commits: &[collector::MasterCommit],
867-
stat: Stat,
867+
metric: Metric,
868868
) -> Result<Self, BoxedError> {
869869
let mut historical_data = HashMap::new();
870870

@@ -881,12 +881,12 @@ impl HistoricalDataMap {
881881
});
882882
}
883883

884-
// get all crates, cache, and profile combinations for the given stat
884+
// get all crates, cache, and profile combinations for the given metric
885885
let query = selector::Query::new()
886886
.set::<String>(Tag::Benchmark, selector::Selector::All)
887887
.set::<String>(Tag::Scenario, selector::Selector::All)
888888
.set::<String>(Tag::Profile, selector::Selector::All)
889-
.set(Tag::Metric, selector::Selector::One(stat.as_str()));
889+
.set(Tag::Metric, selector::Selector::One(metric.as_str()));
890890

891891
let mut previous_commit_series = ctxt
892892
.statistic_series(query, previous_commits.clone())

site/src/github.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::api::github::Issue;
22
use crate::comparison::{
33
deserves_attention_icount, write_summary_table, write_summary_table_footer, ArtifactComparison,
4-
ArtifactComparisonSummary, Direction, Stat,
4+
ArtifactComparisonSummary, Direction, Metric,
55
};
66
use crate::load::{Config, SiteCtxt, TryCommit};
77

@@ -571,7 +571,7 @@ async fn post_comparison_comment(ctxt: &SiteCtxt, commit: QueuedCommit, is_maste
571571
post_comment(&ctxt.config, pr, body).await;
572572
}
573573

574-
fn make_comparison_url(commit: &QueuedCommit, stat: Stat) -> String {
574+
fn make_comparison_url(commit: &QueuedCommit, stat: Metric) -> String {
575575
format!(
576576
"https://perf.rust-lang.org/compare.html?start={}&end={}&stat={}",
577577
commit.parent_sha,
@@ -580,15 +580,15 @@ fn make_comparison_url(commit: &QueuedCommit, stat: Stat) -> String {
580580
)
581581
}
582582

583-
async fn calculate_stat_comparison(
583+
async fn calculate_metric_comparison(
584584
ctxt: &SiteCtxt,
585585
commit: &QueuedCommit,
586-
stat: Stat,
586+
metric: Metric,
587587
) -> Result<ArtifactComparison, String> {
588588
match crate::comparison::compare(
589589
collector::Bound::Commit(commit.parent_sha.clone()),
590590
collector::Bound::Commit(commit.sha.clone()),
591-
stat,
591+
metric,
592592
ctxt,
593593
)
594594
.await
@@ -608,10 +608,10 @@ async fn summarize_run(
608608
let mut message = format!(
609609
"Finished benchmarking commit ({sha}): [comparison url]({comparison_url}).\n\n",
610610
sha = commit.sha,
611-
comparison_url = make_comparison_url(&commit, Stat::Instructions)
611+
comparison_url = make_comparison_url(&commit, Metric::Instructions)
612612
);
613613

614-
let inst_comparison = calculate_stat_comparison(ctxt, &commit, Stat::Instructions).await?;
614+
let inst_comparison = calculate_metric_comparison(ctxt, &commit, Metric::Instructions).await?;
615615

616616
let errors = if !inst_comparison.newly_failed_benchmarks.is_empty() {
617617
let benchmarks = inst_comparison
@@ -629,35 +629,35 @@ async fn summarize_run(
629629
.summarize_by_category(&benchmark_map);
630630

631631
let mut table_written = false;
632-
let stats = vec![
632+
let metrics = vec![
633633
(
634634
"Instruction count",
635-
Stat::Instructions,
635+
Metric::Instructions,
636636
false,
637637
inst_comparison,
638638
),
639639
(
640640
"Max RSS (memory usage)",
641-
Stat::MaxRSS,
641+
Metric::MaxRSS,
642642
true,
643-
calculate_stat_comparison(ctxt, &commit, Stat::MaxRSS).await?,
643+
calculate_metric_comparison(ctxt, &commit, Metric::MaxRSS).await?,
644644
),
645645
(
646646
"Cycles",
647-
Stat::Cycles,
647+
Metric::Cycles,
648648
true,
649-
calculate_stat_comparison(ctxt, &commit, Stat::Cycles).await?,
649+
calculate_metric_comparison(ctxt, &commit, Metric::Cycles).await?,
650650
),
651651
];
652652

653-
for (title, stat, hidden, comparison) in stats {
653+
for (title, metric, hidden, comparison) in metrics {
654654
message.push_str(&format!(
655655
"\n### [{title}]({})\n",
656-
make_comparison_url(&commit, stat)
656+
make_comparison_url(&commit, metric)
657657
));
658658

659659
let (primary, secondary) = comparison.summarize_by_category(&benchmark_map);
660-
table_written |= write_stat_summary(primary, secondary, hidden, &mut message).await;
660+
table_written |= write_metric_summary(primary, secondary, hidden, &mut message).await;
661661
}
662662

663663
if table_written {
@@ -677,7 +677,7 @@ async fn summarize_run(
677677
}
678678

679679
/// Returns true if a summary table was written to `message`.
680-
async fn write_stat_summary(
680+
async fn write_metric_summary(
681681
primary: ArtifactComparisonSummary,
682682
secondary: ArtifactComparisonSummary,
683683
hidden: bool,

0 commit comments

Comments
 (0)