Revive the -T aka --time-passes argument to report run times on the CLI;

This commit is contained in:
Benjamin Bouvier
2018-10-15 20:17:25 +02:00
committed by Dan Gohman
parent 58229e10bf
commit af0a239539
5 changed files with 54 additions and 9 deletions

View File

@@ -35,6 +35,7 @@ extern crate num_cpus;
#[macro_use]
extern crate log;
use cranelift_codegen::timing;
use cranelift_reader::TestCommand;
use runner::TestRunner;
use std::path::Path;
@@ -73,8 +74,8 @@ type TestResult = Result<time::Duration, String>;
/// Directories are scanned recursively for test cases ending in `.clif`. These test cases are
/// executed on background threads.
///
pub fn run(verbose: bool, files: &[String]) -> TestResult {
let mut runner = TestRunner::new(verbose);
pub fn run(verbose: bool, report_times: bool, files: &[String]) -> TestResult {
let mut runner = TestRunner::new(verbose, report_times);
for path in files.iter().map(Path::new) {
if path.is_file() {
@@ -93,8 +94,14 @@ pub fn run(verbose: bool, files: &[String]) -> TestResult {
///
/// Directories are scanned recursively for test cases ending in `.clif`.
///
pub fn run_passes(verbose: bool, passes: &[String], target: &str, file: &str) -> TestResult {
let mut runner = TestRunner::new(verbose);
pub fn run_passes(
verbose: bool,
report_times: bool,
passes: &[String],
target: &str,
file: &str,
) -> TestResult {
let mut runner = TestRunner::new(verbose, /* report_times */ false);
let path = Path::new(file);
if path == Path::new("-") || path.is_file() {
@@ -103,7 +110,11 @@ pub fn run_passes(verbose: bool, passes: &[String], target: &str, file: &str) ->
runner.push_dir(path);
}
runner.run_passes(passes, target)
let result = runner.run_passes(passes, target);
if report_times {
println!("{}", timing::take_current());
}
result
}
/// Create a new subcommand trait object to match `parsed.command`.