Skip to content

Commit 7296b7e

Browse files
committed
Include elapsed time in non-interactive download message
1 parent c695735 commit 7296b7e

File tree

4 files changed

+22
-4
lines changed

4 files changed

+22
-4
lines changed

Cargo.lock

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ clap = { version = "4.3.0", features = [
2626
] }
2727
dirs = "5.0.0"
2828
fs-err = "3.0.0"
29+
humantime = "2.1.0"
2930
indicatif = "0.17.2"
3031
native-tls-crate = { package = "native-tls", version = "0.2.11", optional = true }
3132
paste = "1.0.12"

src/compiler/clang.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use std::env;
22
use std::path::{Path, PathBuf};
33
use std::process::Command;
4+
use std::time::{Duration, Instant};
45

56
use anyhow::{Context, Result};
67
use fs_err as fs;
@@ -202,15 +203,19 @@ impl Clang {
202203
pb.set_prefix("sysroot");
203204
pb.set_message("📥 downloading");
204205
if pb.is_hidden() {
205-
eprintln!("📥 Start downloading MSVC sysroot...");
206+
eprintln!("📥 Downloading MSVC sysroot...");
206207
}
208+
let start_time = Instant::now();
207209
let reader = pb.wrap_read(response.into_reader());
208210
let tar = XzDecoder::new(reader);
209211
let mut archive = tar::Archive::new(tar);
210212
archive.unpack(cache_dir)?;
211213
pb.finish_with_message("Download completed");
212214
if pb.is_hidden() {
213-
eprintln!("✅ Finished downloading MSVC sysroot.");
215+
// Display elapsed time in human-readable format to seconds only
216+
let elapsed =
217+
humantime::format_duration(Duration::from_secs(start_time.elapsed().as_secs()));
218+
eprintln!("✅ Downloaded MSVC sysroot in {elapsed}.");
214219
}
215220
Ok(())
216221
}

src/compiler/clang_cl.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use std::env;
44
use std::ffi::OsStr;
55
use std::path::{Path, PathBuf};
66
use std::process::Command;
7+
use std::time::{Duration, Instant};
78

89
use anyhow::{Context, Result};
910
use fs_err as fs;
@@ -248,8 +249,9 @@ impl<'a> ClangCl<'a> {
248249

249250
mp.set_move_cursor(true);
250251
if mp.is_hidden() {
251-
eprintln!("⏬ Start downloading MSVC CRT...");
252+
eprintln!("⏬ Downloading MSVC CRT...");
252253
}
254+
let start_time = Instant::now();
253255
ctx.execute(
254256
pkgs,
255257
work_items,
@@ -277,7 +279,10 @@ impl<'a> ClangCl<'a> {
277279
let _ = fs::remove_dir_all(unpack);
278280
}
279281
if mp.is_hidden() {
280-
eprintln!("✅ Finished downloading MSVC CRT.");
282+
// Display elapsed time in human-readable format to seconds only
283+
let elapsed =
284+
humantime::format_duration(Duration::from_secs(start_time.elapsed().as_secs()));
285+
eprintln!("✅ Downloaded MSVC CRT in {elapsed}.");
281286
}
282287
Ok(())
283288
}

0 commit comments

Comments
 (0)