Rollup merge of #107718 - Zoxc:z-time, r=nnethercote
Add `-Z time-passes-format` to allow specifying a JSON output for `-Z time-passes` This adds back the `-Z time` option as that is useful for [my rustc benchmark tool](https://github.com/Zoxc/rcb), reverting https://github.com/rust-lang/rust/pull/102725. It now uses nanoseconds and bytes as the units so it is renamed to `time-precise`.
This commit is contained in:
commit
acd7f878ae
13 changed files with 107 additions and 32 deletions
|
@ -20,7 +20,9 @@ pub extern crate rustc_plugin_impl as plugin;
|
|||
|
||||
use rustc_ast as ast;
|
||||
use rustc_codegen_ssa::{traits::CodegenBackend, CodegenErrors, CodegenResults};
|
||||
use rustc_data_structures::profiling::{get_resident_set_size, print_time_passes_entry};
|
||||
use rustc_data_structures::profiling::{
|
||||
get_resident_set_size, print_time_passes_entry, TimePassesFormat,
|
||||
};
|
||||
use rustc_data_structures::sync::SeqCst;
|
||||
use rustc_errors::registry::{InvalidErrorCode, Registry};
|
||||
use rustc_errors::{
|
||||
|
@ -161,7 +163,7 @@ pub trait Callbacks {
|
|||
|
||||
#[derive(Default)]
|
||||
pub struct TimePassesCallbacks {
|
||||
time_passes: bool,
|
||||
time_passes: Option<TimePassesFormat>,
|
||||
}
|
||||
|
||||
impl Callbacks for TimePassesCallbacks {
|
||||
|
@ -171,7 +173,8 @@ impl Callbacks for TimePassesCallbacks {
|
|||
// If a --print=... option has been given, we don't print the "total"
|
||||
// time because it will mess up the --print output. See #64339.
|
||||
//
|
||||
self.time_passes = config.opts.prints.is_empty() && config.opts.unstable_opts.time_passes;
|
||||
self.time_passes = (config.opts.prints.is_empty() && config.opts.unstable_opts.time_passes)
|
||||
.then(|| config.opts.unstable_opts.time_passes_format);
|
||||
config.opts.trimmed_def_paths = TrimmedDefPaths::GoodPath;
|
||||
}
|
||||
}
|
||||
|
@ -1354,9 +1357,9 @@ pub fn main() -> ! {
|
|||
RunCompiler::new(&args, &mut callbacks).run()
|
||||
});
|
||||
|
||||
if callbacks.time_passes {
|
||||
if let Some(format) = callbacks.time_passes {
|
||||
let end_rss = get_resident_set_size();
|
||||
print_time_passes_entry("total", start_time.elapsed(), start_rss, end_rss);
|
||||
print_time_passes_entry("total", start_time.elapsed(), start_rss, end_rss, format);
|
||||
}
|
||||
|
||||
process::exit(exit_code)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue