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:
@@ -24,10 +24,8 @@
|
||||
|
||||
pub use crate::function_runner::TestFileCompiler;
|
||||
use crate::runner::TestRunner;
|
||||
use cranelift_codegen::timing;
|
||||
use cranelift_reader::TestCommand;
|
||||
use std::path::Path;
|
||||
use std::time;
|
||||
|
||||
mod concurrent;
|
||||
pub mod function_runner;
|
||||
@@ -63,7 +61,7 @@ mod test_wasm;
|
||||
/// Directories are scanned recursively for test cases ending in `.clif`. These test cases are
|
||||
/// executed on background threads.
|
||||
///
|
||||
pub fn run(verbose: bool, report_times: bool, files: &[String]) -> anyhow::Result<time::Duration> {
|
||||
pub fn run(verbose: bool, report_times: bool, files: &[String]) -> anyhow::Result<()> {
|
||||
let mut runner = TestRunner::new(verbose, report_times);
|
||||
|
||||
for path in files.iter().map(Path::new) {
|
||||
@@ -89,8 +87,8 @@ pub fn run_passes(
|
||||
passes: &[String],
|
||||
target: &str,
|
||||
file: &str,
|
||||
) -> anyhow::Result<time::Duration> {
|
||||
let mut runner = TestRunner::new(verbose, /* report_times */ false);
|
||||
) -> anyhow::Result<()> {
|
||||
let mut runner = TestRunner::new(verbose, report_times);
|
||||
|
||||
let path = Path::new(file);
|
||||
if path == Path::new("-") || path.is_file() {
|
||||
@@ -99,11 +97,8 @@ pub fn run_passes(
|
||||
runner.push_dir(path);
|
||||
}
|
||||
|
||||
let result = runner.run_passes(passes, target);
|
||||
if report_times {
|
||||
println!("{}", timing::take_current());
|
||||
}
|
||||
result
|
||||
runner.start_threads();
|
||||
runner.run_passes(passes, target)
|
||||
}
|
||||
|
||||
/// Create a new subcommand trait object to match `parsed.command`.
|
||||
|
||||
Reference in New Issue
Block a user