Skip to content

Commit 329ee4a

Browse files
committed
Inline and remove bench_next.
It has a single call site. Also rearrange it a bit, particularly so the error handling is nicer and more like that of the other subcommands.
1 parent a6faa14 commit 329ee4a

File tree

1 file changed

+35
-50
lines changed

1 file changed

+35
-50
lines changed

collector/src/main.rs

Lines changed: 35 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ extern crate clap;
66
use anyhow::{bail, Context};
77
use collector::api::collected;
88
use database::{pool::Connection, ArtifactId, Commit};
9-
use log::{debug, error};
9+
use log::debug;
1010
use std::collections::HashSet;
1111
use std::fs;
1212
use std::io::{stderr, Write};
@@ -162,54 +162,6 @@ where
162162
Ok(v)
163163
}
164164

165-
fn bench_next(
166-
rt: &mut Runtime,
167-
site_url: &str,
168-
pool: &database::Pool,
169-
benchmarks: &[Benchmark],
170-
self_profile: bool,
171-
) -> anyhow::Result<()> {
172-
println!("processing commits");
173-
let client = reqwest::blocking::Client::new();
174-
let response: collector::api::next_commit::Response = client
175-
.get(&format!("{}/perf/next_commit", site_url))
176-
.send()?
177-
.json()?;
178-
let commit = if let Some(c) = response.commit {
179-
c
180-
} else {
181-
println!("no commit to benchmark");
182-
// no missing commits
183-
return Ok(());
184-
};
185-
186-
let commit = get_commit_or_fake_it(&commit)?;
187-
match Sysroot::install(commit.sha.to_string(), "x86_64-unknown-linux-gnu") {
188-
Ok(sysroot) => {
189-
let conn = rt.block_on(pool.connection());
190-
bench(
191-
rt,
192-
conn,
193-
&ArtifactId::Commit(commit),
194-
&BuildKind::all(),
195-
&RunKind::all(),
196-
Compiler::from_sysroot(&sysroot),
197-
&benchmarks,
198-
3,
199-
/* call_home */ true,
200-
self_profile,
201-
);
202-
}
203-
Err(err) => {
204-
error!("failed to install sysroot for {:?}: {:?}", commit, err);
205-
}
206-
}
207-
208-
client.post(&format!("{}/perf/onpush", site_url)).send()?;
209-
210-
Ok(())
211-
}
212-
213165
fn n_benchmarks_remaining(n: usize) -> String {
214166
let suffix = if n == 1 { "" } else { "s" };
215167
format!("{} benchmark{} remaining", n, suffix)
@@ -616,11 +568,44 @@ fn main_result() -> anyhow::Result<i32> {
616568
let db = sub_m.value_of("DB").unwrap_or(default_db);
617569
let self_profile = sub_m.is_present("SELF_PROFILE");
618570

571+
println!("processing commits");
572+
let client = reqwest::blocking::Client::new();
573+
let response: collector::api::next_commit::Response = client
574+
.get(&format!("{}/perf/next_commit", site_url))
575+
.send()?
576+
.json()?;
577+
let commit = if let Some(c) = response.commit {
578+
c
579+
} else {
580+
println!("no commit to benchmark");
581+
// no missing commits
582+
return Ok(0);
583+
};
584+
let commit = get_commit_or_fake_it(&commit)?;
585+
619586
let pool = database::Pool::open(db);
587+
let conn = rt.block_on(pool.connection());
588+
589+
let sysroot = Sysroot::install(commit.sha.to_string(), "x86_64-unknown-linux-gnu")
590+
.with_context(|| format!("failed to install sysroot for {:?}", commit))?;
620591

621592
let benchmarks = get_benchmarks(&benchmark_dir, None, None)?;
622593

623-
bench_next(&mut rt, &site_url, &pool, &benchmarks, self_profile)?;
594+
bench(
595+
&mut rt,
596+
conn,
597+
&ArtifactId::Commit(commit),
598+
&BuildKind::all(),
599+
&RunKind::all(),
600+
Compiler::from_sysroot(&sysroot),
601+
&benchmarks,
602+
3,
603+
/* call_home */ true,
604+
self_profile,
605+
);
606+
607+
client.post(&format!("{}/perf/onpush", site_url)).send()?;
608+
624609
Ok(0)
625610
}
626611

0 commit comments

Comments
 (0)