Support plugging external profilers into the Cranelift timing infrastructure (#5749)

* Remove no-std code for cranelift_codegen::timings

no-std mode isn't supported by Cranelift anymore

* Simplify define_passes macro

* Add egraph opt timings

* Replace the add_to_current api with PassTimes::add

* Omit a couple of unused time measurements

* Reduce divergence between run and run_passes a bit

* Introduce a Profiler trait

This allows plugging in external profilers into the Cranelift profiling
framework.

* Add Pass::description method

* Remove duplicate usage of the compile pass timing

* Rustfmt
This commit is contained in:
bjorn3
2023-03-10 20:33:56 +01:00
committed by GitHub
parent 0751cba6e2
commit 108f7917c8
5 changed files with 181 additions and 181 deletions

View File

@@ -5,7 +5,6 @@
use crate::concurrent::{ConcurrentRunner, Reply};
use crate::runone;
use cranelift_codegen::timing;
use std::error::Error;
use std::ffi::OsStr;
use std::fmt::{self, Display};
@@ -298,9 +297,9 @@ impl TestRunner {
None => break,
}
}
conc.join();
let pass_times = conc.join();
if self.report_times {
println!("{}", timing::take_current());
println!("{}", pass_times);
}
}
}
@@ -355,8 +354,7 @@ impl TestRunner {
}
/// Scan pushed directories for tests and run them.
pub fn run(&mut self) -> anyhow::Result<time::Duration> {
let started = time::Instant::now();
pub fn run(&mut self) -> anyhow::Result<()> {
self.scan_dirs(IsPass::NotPass);
self.schedule_jobs();
self.report_slow_tests();
@@ -364,26 +362,22 @@ impl TestRunner {
println!("{} tests", self.tests.len());
match self.errors {
0 => Ok(started.elapsed()),
0 => Ok(()),
1 => anyhow::bail!("1 failure"),
n => anyhow::bail!("{} failures", n),
}
}
/// Scan pushed directories for tests and run specified passes from commandline on them.
pub fn run_passes(
&mut self,
passes: &[String],
target: &str,
) -> anyhow::Result<time::Duration> {
let started = time::Instant::now();
pub fn run_passes(&mut self, passes: &[String], target: &str) -> anyhow::Result<()> {
self.scan_dirs(IsPass::Pass);
self.schedule_pass_job(passes, target);
self.report_slow_tests();
self.drain_threads();
println!("{} tests", self.tests.len());
match self.errors {
0 => Ok(started.elapsed()),
0 => Ok(()),
1 => anyhow::bail!("1 failure"),
n => anyhow::bail!("{} failures", n),
}