Skip to content

Commit 0701fb6

Browse files
committed
Parse profiles in GitHub commands and mention them in help
1 parent f8a61f3 commit 0701fb6

File tree

3 files changed

+39
-6
lines changed

3 files changed

+39
-6
lines changed

database/src/lib.rs

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,17 @@ impl Profile {
232232
pub fn default_profiles() -> Vec<Self> {
233233
vec![Profile::Check, Profile::Debug, Profile::Doc, Profile::Opt]
234234
}
235+
236+
pub fn all_values() -> &'static [Self] {
237+
&[
238+
Self::Check,
239+
Self::Debug,
240+
Self::Opt,
241+
Self::Doc,
242+
Self::DocJson,
243+
Self::Clippy,
244+
]
245+
}
235246
}
236247

237248
impl std::str::FromStr for Profile {
@@ -1023,11 +1034,7 @@ impl BenchmarkRequest {
10231034
return Ok(Profile::default_profiles());
10241035
}
10251036

1026-
self.profiles
1027-
.split(',')
1028-
.map(Profile::from_str)
1029-
.collect::<Result<Vec<_>, _>>()
1030-
.map_err(|e| anyhow::anyhow!("Invalid profile: {e}"))
1037+
parse_profiles(&self.profiles).map_err(|e| anyhow::anyhow!("{e}"))
10311038
}
10321039

10331040
pub fn is_completed(&self) -> bool {
@@ -1046,6 +1053,13 @@ pub fn parse_backends(backends: &str) -> Result<Vec<CodegenBackend>, String> {
10461053
.collect()
10471054
}
10481055

1056+
pub fn parse_profiles(profiles: &str) -> Result<Vec<Profile>, String> {
1057+
profiles
1058+
.split(',')
1059+
.map(|s| Profile::from_str(s).map_err(|_| format!("Invalid profile: {s}")))
1060+
.collect()
1061+
}
1062+
10491063
/// Cached information about benchmark requests in the DB
10501064
pub struct BenchmarkRequestIndex {
10511065
/// Tags (SHA or release name) of all known benchmark requests

site/frontend/templates/pages/help.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ <h3><b><code>@rust-timer</code> commands</b></h3>
4949
rustc-perf will also gather data for this backend for the parent/baseline commit, so that we
5050
have something to compare to.
5151
</li>
52+
<li><code>profiles=&lt;PROFILES&gt;</code> configures which profiles should be benchmarked.
53+
If you select a non-default profile, rustc-perf will also gather data for this profile for the
54+
parent/baseline commit, so that we have something to compare to.
55+
</li>
5256
</ul>
5357
<p><code>@rust-timer build $commit</code> will queue a perf run for the given commit
5458
<code>$commit</code>.

site/src/request_handlers/github.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::github::{
66
use crate::job_queue::should_use_job_queue;
77
use crate::load::SiteCtxt;
88

9-
use database::{parse_backends, BenchmarkRequest, CodegenBackend};
9+
use database::{parse_backends, parse_profiles, BenchmarkRequest, CodegenBackend, Profile};
1010
use hashbrown::HashMap;
1111
use std::sync::Arc;
1212

@@ -258,6 +258,7 @@ fn parse_benchmark_parameters<'a>(
258258
exclude: args.remove("exclude").filter(|s| !s.is_empty()),
259259
runs: None,
260260
backends: args.remove("backends").filter(|s| !s.is_empty()),
261+
profiles: args.remove("profiles").filter(|s| !s.is_empty()),
261262
};
262263
if let Some(runs) = args.remove("runs").filter(|s| !s.is_empty()) {
263264
let Ok(runs) = runs.parse::<u32>() else {
@@ -278,6 +279,19 @@ fn parse_benchmark_parameters<'a>(
278279
)
279280
})?;
280281
}
282+
if let Some(profiles) = &params.profiles {
283+
// Make sure that the profiles are correct
284+
parse_profiles(profiles).map_err(|e| {
285+
format!(
286+
"Cannot parse profiles: {e}. Valid values are: {}",
287+
Profile::all_values()
288+
.iter()
289+
.map(|b| b.as_str())
290+
.collect::<Vec<_>>()
291+
.join(", ")
292+
)
293+
})?;
294+
}
281295

282296
if !args.is_empty() {
283297
Err(format!(
@@ -327,6 +341,7 @@ struct BenchmarkParameters<'a> {
327341
exclude: Option<&'a str>,
328342
runs: Option<i32>,
329343
backends: Option<&'a str>,
344+
profiles: Option<&'a str>,
330345
}
331346

332347
pub async fn get_authorized_users() -> Result<Vec<u64>, String> {

0 commit comments

Comments
 (0)