Only display codegen time when CG_CLIF_DISPLAY_CG_TIME=1

This commit is contained in:
bjorn3 2020-07-03 16:43:26 +02:00
parent 798fb85651
commit 92dc61aba2
2 changed files with 2 additions and 2 deletions

View File

@ -69,7 +69,7 @@ function jit_calc() {
to make it possible to use incremental mode for all analyses performed by rustc without caching
object files when their content should have been changed by a change to cg_clif.</dd>
<dt>CG_CLIF_DISPLAY_CG_TIME</dt>
<dd>Display the time it took to perform codegen for a crate</dd>
<dd>If "1", display the time it took to perform codegen for a crate</dd>
</dl>
## Not yet supported

View File

@ -109,7 +109,7 @@ fn trans_mono_item<'tcx, B: Backend + 'static>(
}
fn time<R>(tcx: TyCtxt<'_>, name: &'static str, f: impl FnOnce() -> R) -> R {
if std::env::var("CG_CLIF_DISPLAY_CG_TIME").is_ok() {
if std::env::var("CG_CLIF_DISPLAY_CG_TIME").as_ref().map(|val| &**val) == Ok("1") {
println!("[{:<30}: {}] start", tcx.crate_name(LOCAL_CRATE), name);
let before = std::time::Instant::now();
let res = tcx.sess.time(name, f);