Skip to content

Commit f32dc7c

Browse files
committed
Implement conversions from collector benchmark parameters to database benchmark parameters
1 parent b776483 commit f32dc7c

File tree

5 files changed

+40
-26
lines changed

5 files changed

+40
-26
lines changed

collector/src/compile/benchmark/codegen_backend.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,12 @@ impl CodegenBackend {
1010
vec![CodegenBackend::Llvm, CodegenBackend::Cranelift]
1111
}
1212
}
13+
14+
impl From<CodegenBackend> for database::CodegenBackend {
15+
fn from(value: CodegenBackend) -> Self {
16+
match value {
17+
CodegenBackend::Llvm => database::CodegenBackend::Llvm,
18+
CodegenBackend::Cranelift => database::CodegenBackend::Cranelift,
19+
}
20+
}
21+
}

collector/src/compile/benchmark/mod.rs

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -334,11 +334,7 @@ impl Benchmark {
334334
return Ok(());
335335
}
336336

337-
eprintln!(
338-
"Preparing {} (test cases: {})",
339-
self.name,
340-
benchmark_dirs.len()
341-
);
337+
eprintln!("Preparing {}", self.name);
342338

343339
// In parallel (but with a limit to the number of CPUs), prepare all
344340
// profiles. This is done in parallel vs. sequentially because:
@@ -456,7 +452,7 @@ impl Benchmark {
456452

457453
// Rustdoc does not support incremental compilation
458454
if !profile.is_doc() {
459-
// An incremental from scratch (slowest incremental case).
455+
// An incremental build from scratch (slowest incremental case).
460456
// This is required for any subsequent incremental builds.
461457
if scenarios.iter().any(|s| s.is_incr()) {
462458
self.mk_cargo_process(toolchain, cwd, profile, backend, target)
@@ -529,21 +525,9 @@ impl Benchmark {
529525
}
530526

531527
let benchmark = database::Benchmark::from(self.name.0.as_str());
532-
let profile = match profile {
533-
Profile::Check => database::Profile::Check,
534-
Profile::Debug => database::Profile::Debug,
535-
Profile::Doc => database::Profile::Doc,
536-
Profile::DocJson => database::Profile::DocJson,
537-
Profile::Opt => database::Profile::Opt,
538-
Profile::Clippy => database::Profile::Clippy,
539-
};
540-
let backend = match backend {
541-
CodegenBackend::Llvm => database::CodegenBackend::Llvm,
542-
CodegenBackend::Cranelift => database::CodegenBackend::Cranelift,
543-
};
544-
let target = match target {
545-
Target::X86_64UnknownLinuxGnu => database::Target::X86_64UnknownLinuxGnu,
546-
};
528+
let profile: database::Profile = (*profile).into();
529+
let backend: database::CodegenBackend = (*backend).into();
530+
let target: database::Target = (*target).into();
547531

548532
match scenario {
549533
// For these scenarios, we can simply check if they were benchmarked or not

collector/src/compile/benchmark/profile.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,16 @@ impl Profile {
4141
}
4242
}
4343
}
44+
45+
impl From<Profile> for database::Profile {
46+
fn from(value: Profile) -> Self {
47+
match value {
48+
Profile::Check => database::Profile::Check,
49+
Profile::Debug => database::Profile::Debug,
50+
Profile::Doc => database::Profile::Doc,
51+
Profile::DocJson => database::Profile::DocJson,
52+
Profile::Opt => database::Profile::Opt,
53+
Profile::Clippy => database::Profile::Clippy,
54+
}
55+
}
56+
}

collector/src/compile/benchmark/target.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,20 @@ impl Target {
1919
pub fn all() -> Vec<Self> {
2020
vec![Self::X86_64UnknownLinuxGnu]
2121
}
22+
}
2223

23-
pub fn from_db_target(target: &database::Target) -> Target {
24-
match target {
24+
impl From<database::Target> for Target {
25+
fn from(value: database::Target) -> Self {
26+
match value {
2527
database::Target::X86_64UnknownLinuxGnu => Self::X86_64UnknownLinuxGnu,
2628
}
2729
}
2830
}
31+
32+
impl From<Target> for database::Target {
33+
fn from(value: Target) -> Self {
34+
match value {
35+
Target::X86_64UnknownLinuxGnu => database::Target::X86_64UnknownLinuxGnu,
36+
}
37+
}
38+
}

site/src/job_queue/mod.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,7 @@ pub async fn enqueue_benchmark_request(
197197

198198
// Target x benchmark_set x backend x profile -> BenchmarkJob
199199
for target in Target::all() {
200-
for benchmark_set in 0..benchmark_set_count(
201-
collector::compile::benchmark::target::Target::from_db_target(&target),
202-
) {
200+
for benchmark_set in 0..benchmark_set_count(target.into()) {
203201
for backend in backends.iter() {
204202
for profile in profiles.iter() {
205203
tx.conn()

0 commit comments

Comments
 (0)