Skip to content

Commit b792e8f

Browse files
committed
Parse profiles in GitHub commands and mention them in help
1 parent 54257f3 commit b792e8f

File tree

3 files changed

+42
-6
lines changed

3 files changed

+42
-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 {
@@ -1056,6 +1063,13 @@ pub fn parse_backends(backends: &str) -> Result<Vec<CodegenBackend>, String> {
10561063
.collect()
10571064
}
10581065

1066+
pub fn parse_profiles(profiles: &str) -> Result<Vec<Profile>, String> {
1067+
profiles
1068+
.split(',')
1069+
.map(|s| Profile::from_str(s).map_err(|_| format!("Invalid profile: {s}")))
1070+
.collect()
1071+
}
1072+
10591073
/// Cached information about benchmark requests in the DB
10601074
pub struct BenchmarkRequestIndex {
10611075
/// 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: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ use crate::github::{
66
use crate::job_queue::should_use_job_queue;
77
use crate::load::SiteCtxt;
88

9-
use database::{parse_backends, BenchmarkRequest, BenchmarkRequestInsertResult, CodegenBackend};
9+
use database::{
10+
parse_backends, parse_profiles, BenchmarkRequest, BenchmarkRequestInsertResult, CodegenBackend,
11+
Profile,
12+
};
1013
use hashbrown::HashMap;
1114
use std::sync::Arc;
1215

@@ -277,6 +280,7 @@ fn parse_benchmark_parameters<'a>(
277280
exclude: args.remove("exclude").filter(|s| !s.is_empty()),
278281
runs: None,
279282
backends: args.remove("backends").filter(|s| !s.is_empty()),
283+
profiles: args.remove("profiles").filter(|s| !s.is_empty()),
280284
};
281285
if let Some(runs) = args.remove("runs").filter(|s| !s.is_empty()) {
282286
let Ok(runs) = runs.parse::<u32>() else {
@@ -297,6 +301,19 @@ fn parse_benchmark_parameters<'a>(
297301
)
298302
})?;
299303
}
304+
if let Some(profiles) = &params.profiles {
305+
// Make sure that the profiles are correct
306+
parse_profiles(profiles).map_err(|e| {
307+
format!(
308+
"Cannot parse profiles: {e}. Valid values are: {}",
309+
Profile::all_values()
310+
.iter()
311+
.map(|b| b.as_str())
312+
.collect::<Vec<_>>()
313+
.join(", ")
314+
)
315+
})?;
316+
}
300317

301318
if !args.is_empty() {
302319
Err(format!(
@@ -346,6 +363,7 @@ struct BenchmarkParameters<'a> {
346363
exclude: Option<&'a str>,
347364
runs: Option<i32>,
348365
backends: Option<&'a str>,
366+
profiles: Option<&'a str>,
349367
}
350368

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

0 commit comments

Comments
 (0)