Auto merge of #5456 - LukasKalbertodt:patch-1, r=matklad

Show elapsed time in minutes if >= 60 secs

In large projects with long compile times, seeing "428.65 secs" isn't as clear to humans as seeing the number of minutes (and seconds).

**Old**:
```
Finished dev [unoptimized + debuginfo] target(s) in 2.23 secs
Finished dev [unoptimized + debuginfo] target(s) in 63.94 secs
Finished dev [unoptimized + debuginfo] target(s) in 428.65 secs
```

**New**:
```
Finished dev [unoptimized + debuginfo] target(s) in 2.23s
Finished dev [unoptimized + debuginfo] target(s) in 1m 3.94s
Finished dev [unoptimized + debuginfo] target(s) in 7m 8.65s
```

Note that I also changed `secs` to `s`, because `7 mins 8.65 secs` and `7m 8.65 secs` both look strange IMO. But if you disagree and you'd prefer `secs`, just tell me and I'll change it.

I *didn't* add a check for `secs >= 3600` to print the time in hours. I *hope* this is not necessary...
This commit is contained in:
bors 2018-05-02 17:17:27 +00:00
commit 420f9ec576
5 changed files with 53 additions and 35 deletions

View File

@ -275,12 +275,30 @@ impl<'a> JobQueue<'a> {
if profile.debuginfo.is_some() { if profile.debuginfo.is_some() {
opt_type += " + debuginfo"; opt_type += " + debuginfo";
} }
let time_elapsed = {
use std::fmt::Write;
let duration = cx.bcx.config.creation_time().elapsed(); let duration = cx.bcx.config.creation_time().elapsed();
let time_elapsed = format!( let mut s = String::new();
"{}.{:02} secs", let secs = duration.as_secs();
duration.as_secs(),
if secs >= 60 {
// We can safely unwrap, as writing to a `String` never errors
write!(s, "{}m ", secs / 60).unwrap();
};
// We can safely unwrap, as writing to a `String` never errors
write!(
s,
"{}.{:02}s",
secs % 60,
duration.subsec_nanos() / 10_000_000 duration.subsec_nanos() / 10_000_000
); ).unwrap();
s
};
if self.queue.is_empty() { if self.queue.is_empty() {
let message = format!( let message = format!(
"{} [{}] target(s) in {}", "{} [{}] target(s) in {}",

View File

@ -65,7 +65,7 @@ fn depend_on_alt_registry() {
[DOWNLOADING] bar v0.0.1 (registry `file://[..]`) [DOWNLOADING] bar v0.0.1 (registry `file://[..]`)
[COMPILING] bar v0.0.1 (registry `file://[..]`) [COMPILING] bar v0.0.1 (registry `file://[..]`)
[COMPILING] foo v0.0.1 ({dir}) [COMPILING] foo v0.0.1 ({dir})
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] secs [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
", ",
dir = p.url(), dir = p.url(),
reg = registry::alt_registry() reg = registry::alt_registry()
@ -84,7 +84,7 @@ fn depend_on_alt_registry() {
"\ "\
[COMPILING] bar v0.0.1 (registry `file://[..]`) [COMPILING] bar v0.0.1 (registry `file://[..]`)
[COMPILING] foo v0.0.1 ({dir}) [COMPILING] foo v0.0.1 ({dir})
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] secs [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
", ",
dir = p.url() dir = p.url()
)), )),
@ -128,7 +128,7 @@ fn depend_on_alt_registry_depends_on_same_registry_no_index() {
[COMPILING] baz v0.0.1 (registry `file://[..]`) [COMPILING] baz v0.0.1 (registry `file://[..]`)
[COMPILING] bar v0.0.1 (registry `file://[..]`) [COMPILING] bar v0.0.1 (registry `file://[..]`)
[COMPILING] foo v0.0.1 ({dir}) [COMPILING] foo v0.0.1 ({dir})
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] secs [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
", ",
dir = p.url(), dir = p.url(),
reg = registry::alt_registry() reg = registry::alt_registry()
@ -173,7 +173,7 @@ fn depend_on_alt_registry_depends_on_same_registry() {
[COMPILING] baz v0.0.1 (registry `file://[..]`) [COMPILING] baz v0.0.1 (registry `file://[..]`)
[COMPILING] bar v0.0.1 (registry `file://[..]`) [COMPILING] bar v0.0.1 (registry `file://[..]`)
[COMPILING] foo v0.0.1 ({dir}) [COMPILING] foo v0.0.1 ({dir})
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] secs [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
", ",
dir = p.url(), dir = p.url(),
reg = registry::alt_registry() reg = registry::alt_registry()
@ -219,7 +219,7 @@ fn depend_on_alt_registry_depends_on_crates_io() {
[COMPILING] baz v0.0.1 (registry `file://[..]`) [COMPILING] baz v0.0.1 (registry `file://[..]`)
[COMPILING] bar v0.0.1 (registry `file://[..]`) [COMPILING] bar v0.0.1 (registry `file://[..]`)
[COMPILING] foo v0.0.1 ({dir}) [COMPILING] foo v0.0.1 ({dir})
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] secs [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
", ",
dir = p.url(), dir = p.url(),
alt_reg = registry::alt_registry(), alt_reg = registry::alt_registry(),
@ -267,7 +267,7 @@ fn registry_and_path_dep_works() {
"\ "\
[COMPILING] bar v0.0.1 ({dir}/bar) [COMPILING] bar v0.0.1 ({dir}/bar)
[COMPILING] foo v0.0.1 ({dir}) [COMPILING] foo v0.0.1 ({dir})
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] secs [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
", ",
dir = p.url() dir = p.url()
)), )),
@ -420,7 +420,7 @@ fn alt_registry_and_crates_io_deps() {
.with_stderr_contains("[COMPILING] crates_io_dep v0.0.1") .with_stderr_contains("[COMPILING] crates_io_dep v0.0.1")
.with_stderr_contains(&format!("[COMPILING] foo v0.0.1 ({})", p.url())) .with_stderr_contains(&format!("[COMPILING] foo v0.0.1 ({})", p.url()))
.with_stderr_contains( .with_stderr_contains(
"[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] secs", "[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s",
), ),
) )
} }

View File

@ -170,7 +170,7 @@ fn simple_install() {
" Installing bar v0.1.0 " Installing bar v0.1.0
Compiling foo v0.1.0 Compiling foo v0.1.0
Compiling bar v0.1.0 Compiling bar v0.1.0
Finished release [optimized] target(s) in [..] secs Finished release [optimized] target(s) in [..]s
Installing [..]bar[..] Installing [..]bar[..]
warning: be sure to add `[..]` to your PATH to be able to run the installed binaries warning: be sure to add `[..]` to your PATH to be able to run the installed binaries
", ",
@ -288,7 +288,7 @@ fn install_without_feature_dep() {
" Installing bar v0.1.0 " Installing bar v0.1.0
Compiling foo v0.1.0 Compiling foo v0.1.0
Compiling bar v0.1.0 Compiling bar v0.1.0
Finished release [optimized] target(s) in [..] secs Finished release [optimized] target(s) in [..]s
Installing [..]bar[..] Installing [..]bar[..]
warning: be sure to add `[..]` to your PATH to be able to run the installed binaries warning: be sure to add `[..]` to your PATH to be able to run the installed binaries
", ",

View File

@ -335,7 +335,7 @@ warning: Package `foo v0.0.1 ([..])` does not have feature `bar`. It has a requi
that name, but only optional dependencies can be used as features. [..] that name, but only optional dependencies can be used as features. [..]
Compiling bar v0.0.1 ([..]) Compiling bar v0.0.1 ([..])
Compiling foo v0.0.1 ([..]) Compiling foo v0.0.1 ([..])
Finished dev [unoptimized + debuginfo] target(s) in [..] secs Finished dev [unoptimized + debuginfo] target(s) in [..]s
")); "));
} }
@ -388,7 +388,7 @@ that name, but only optional dependencies can be used as features. [..]
Compiling baz v0.0.1 ([..]) Compiling baz v0.0.1 ([..])
Compiling bar v0.0.1 ([..]) Compiling bar v0.0.1 ([..])
Compiling foo v0.0.1 ([..]) Compiling foo v0.0.1 ([..])
Finished dev [unoptimized + debuginfo] target(s) in [..] secs Finished dev [unoptimized + debuginfo] target(s) in [..]s
")); "));
} }

View File

@ -45,7 +45,7 @@ fn simple() {
[DOWNLOADING] bar v0.0.1 (registry `file://[..]`) [DOWNLOADING] bar v0.0.1 (registry `file://[..]`)
[COMPILING] bar v0.0.1 [COMPILING] bar v0.0.1
[COMPILING] foo v0.0.1 ({dir}) [COMPILING] foo v0.0.1 ({dir})
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] secs [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
", ",
dir = p.url(), dir = p.url(),
reg = registry::registry() reg = registry::registry()
@ -61,7 +61,7 @@ fn simple() {
"\ "\
[COMPILING] bar v0.0.1 [COMPILING] bar v0.0.1
[COMPILING] foo v0.0.1 ({dir}) [COMPILING] foo v0.0.1 ({dir})
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] secs [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
", ",
dir = p.url() dir = p.url()
)), )),
@ -99,7 +99,7 @@ fn deps() {
[COMPILING] baz v0.0.1 [COMPILING] baz v0.0.1
[COMPILING] bar v0.0.1 [COMPILING] bar v0.0.1
[COMPILING] foo v0.0.1 ({dir}) [COMPILING] foo v0.0.1 ({dir})
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] secs [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
", ",
dir = p.url(), dir = p.url(),
reg = registry::registry() reg = registry::registry()
@ -270,7 +270,7 @@ required by package `foo v0.0.1 ([..])`
[DOWNLOADING] notyet v0.0.1 (registry `file://[..]`) [DOWNLOADING] notyet v0.0.1 (registry `file://[..]`)
[COMPILING] notyet v0.0.1 [COMPILING] notyet v0.0.1
[COMPILING] foo v0.0.1 ({dir}) [COMPILING] foo v0.0.1 ({dir})
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] secs [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
", ",
dir = p.url(), dir = p.url(),
reg = registry::registry() reg = registry::registry()
@ -338,7 +338,7 @@ required by package `foo v0.0.1 ([..])`
[DOWNLOADING] notyet v0.0.1 (registry `file://[..]`) [DOWNLOADING] notyet v0.0.1 (registry `file://[..]`)
[COMPILING] notyet v0.0.1 [COMPILING] notyet v0.0.1
[COMPILING] foo v0.0.1 ({dir}[..]) [COMPILING] foo v0.0.1 ({dir}[..])
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] secs [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
", ",
dir = p.url() dir = p.url()
)), )),
@ -373,7 +373,7 @@ fn lockfile_locks() {
[DOWNLOADING] bar v0.0.1 (registry `file://[..]`) [DOWNLOADING] bar v0.0.1 (registry `file://[..]`)
[COMPILING] bar v0.0.1 [COMPILING] bar v0.0.1
[COMPILING] foo v0.0.1 ({dir}) [COMPILING] foo v0.0.1 ({dir})
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] secs [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
", ",
dir = p.url() dir = p.url()
)), )),
@ -416,7 +416,7 @@ fn lockfile_locks_transitively() {
[COMPILING] baz v0.0.1 [COMPILING] baz v0.0.1
[COMPILING] bar v0.0.1 [COMPILING] bar v0.0.1
[COMPILING] foo v0.0.1 ({dir}) [COMPILING] foo v0.0.1 ({dir})
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] secs [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
", ",
dir = p.url() dir = p.url()
)), )),
@ -465,7 +465,7 @@ fn yanks_are_not_used() {
[COMPILING] baz v0.0.1 [COMPILING] baz v0.0.1
[COMPILING] bar v0.0.1 [COMPILING] bar v0.0.1
[COMPILING] foo v0.0.1 ({dir}) [COMPILING] foo v0.0.1 ({dir})
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] secs [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
", ",
dir = p.url() dir = p.url()
)), )),
@ -576,7 +576,7 @@ fn update_with_lockfile_if_packages_missing() {
"\ "\
[UPDATING] registry `[..]` [UPDATING] registry `[..]`
[DOWNLOADING] bar v0.0.1 (registry `file://[..]`) [DOWNLOADING] bar v0.0.1 (registry `file://[..]`)
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] secs [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
", ",
), ),
); );
@ -630,7 +630,7 @@ fn update_lockfile() {
[DOWNLOADING] [..] v0.0.2 (registry `file://[..]`) [DOWNLOADING] [..] v0.0.2 (registry `file://[..]`)
[COMPILING] bar v0.0.2 [COMPILING] bar v0.0.2
[COMPILING] foo v0.0.1 ({dir}) [COMPILING] foo v0.0.1 ({dir})
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] secs [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
", ",
dir = p.url() dir = p.url()
)), )),
@ -655,7 +655,7 @@ fn update_lockfile() {
[DOWNLOADING] [..] v0.0.3 (registry `file://[..]`) [DOWNLOADING] [..] v0.0.3 (registry `file://[..]`)
[COMPILING] bar v0.0.3 [COMPILING] bar v0.0.3
[COMPILING] foo v0.0.1 ({dir}) [COMPILING] foo v0.0.1 ({dir})
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] secs [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
", ",
dir = p.url() dir = p.url()
)), )),
@ -746,7 +746,7 @@ fn dev_dependency_not_used() {
[DOWNLOADING] [..] v0.0.1 (registry `file://[..]`) [DOWNLOADING] [..] v0.0.1 (registry `file://[..]`)
[COMPILING] bar v0.0.1 [COMPILING] bar v0.0.1
[COMPILING] foo v0.0.1 ({dir}) [COMPILING] foo v0.0.1 ({dir})
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] secs [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
", ",
dir = p.url() dir = p.url()
)), )),
@ -858,7 +858,7 @@ fn updating_a_dep() {
[COMPILING] bar v0.0.1 [COMPILING] bar v0.0.1
[COMPILING] a v0.0.1 ({dir}/a) [COMPILING] a v0.0.1 ({dir}/a)
[COMPILING] foo v0.0.1 ({dir}) [COMPILING] foo v0.0.1 ({dir})
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] secs [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
", ",
dir = p.url() dir = p.url()
)), )),
@ -887,7 +887,7 @@ fn updating_a_dep() {
[COMPILING] bar v0.1.0 [COMPILING] bar v0.1.0
[COMPILING] a v0.0.1 ({dir}/a) [COMPILING] a v0.0.1 ({dir}/a)
[COMPILING] foo v0.0.1 ({dir}) [COMPILING] foo v0.0.1 ({dir})
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] secs [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
", ",
dir = p.url() dir = p.url()
)), )),
@ -946,7 +946,7 @@ fn git_and_registry_dep() {
[COMPILING] a v0.0.1 [COMPILING] a v0.0.1
[COMPILING] b v0.0.1 ([..]) [COMPILING] b v0.0.1 ([..])
[COMPILING] foo v0.0.1 ({dir}) [COMPILING] foo v0.0.1 ({dir})
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] secs [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
", ",
dir = p.url() dir = p.url()
)), )),
@ -1022,7 +1022,7 @@ fn update_publish_then_update() {
[DOWNLOADING] a v0.1.1 (registry `file://[..]`) [DOWNLOADING] a v0.1.1 (registry `file://[..]`)
[COMPILING] a v0.1.1 [COMPILING] a v0.1.1
[COMPILING] foo v0.5.0 ({dir}) [COMPILING] foo v0.5.0 ({dir})
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] secs [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
", ",
dir = p.url() dir = p.url()
)), )),
@ -1103,7 +1103,7 @@ fn update_transitive_dependency() {
[COMPILING] b v0.1.1 [COMPILING] b v0.1.1
[COMPILING] a v0.1.0 [COMPILING] a v0.1.0
[COMPILING] foo v0.5.0 ([..]) [COMPILING] foo v0.5.0 ([..])
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] secs [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
", ",
), ),
); );
@ -1361,7 +1361,7 @@ fn only_download_relevant() {
[DOWNLOADING] baz v0.1.0 ([..]) [DOWNLOADING] baz v0.1.0 ([..])
[COMPILING] baz v0.1.0 [COMPILING] baz v0.1.0
[COMPILING] bar v0.5.0 ([..]) [COMPILING] bar v0.5.0 ([..])
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] secs [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
", ",
), ),
); );