From 9ba945059f78a9a564778eda72ca11e267c9ef22 Mon Sep 17 00:00:00 2001 From: holly sparkles Date: Sun, 14 Jan 2024 19:45:45 +0100 Subject: [PATCH] feat: add a stopwatch to time operations --- Cargo.lock | 6 ++++++ Cargo.toml | 1 + src/main.rs | 9 ++++++++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index a0adbe7..c4387e7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -164,9 +164,15 @@ version = "0.1.0" dependencies = [ "git2", "itertools", + "stopwatch", ] [[package]] +name = "stopwatch" +version = "0.1.0" +source = "git+https://git.holly.sh/stopwatch.git#f6221643a92c90649c4568015c7e82d112a68e0b" + +[[package]] name = "tinyvec" version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" diff --git a/Cargo.toml b/Cargo.toml index a89c501..5c1eebb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,3 +8,4 @@ edition = "2021" [dependencies] git2 = "0.18.1" itertools = "0.12.0" +stopwatch = { git = "https://git.holly.sh/stopwatch.git", version = "0.1.0" } diff --git a/src/main.rs b/src/main.rs index 6b41103..39a1cfd 100644 --- a/src/main.rs +++ b/src/main.rs @@ -13,6 +13,9 @@ fn main() { std::process::exit(1); } + let mut stopwatch = stopwatch::Stopwatch::new(); + stopwatch.start(); + let repo_languages: Vec = LanguageDefinitions::default() .load_builtins() .identify_files(repository::get_bare_repository_files(PathBuf::from( @@ -34,5 +37,9 @@ fn main() { sorted_groups .iter() - .for_each(|item| println!("{}: {}", item.0, item.1.len())) + .for_each(|item| println!("{}: {}", item.0, item.1.len())); + + stopwatch.stop(); + + println!("\nOperation complete in {}", stopwatch); } -- libgit2 1.7.2