From 23ab377e50f940e5b26fc341be71daeb9738021e Mon Sep 17 00:00:00 2001 From: laniakea64 Date: Fri, 17 Nov 2023 06:09:25 -0500 Subject: [PATCH] tests: print grand total execution time of all Vim processes --- tests/src/main.rs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/tests/src/main.rs b/tests/src/main.rs index 8bdd659..5db48d5 100644 --- a/tests/src/main.rs +++ b/tests/src/main.rs @@ -12,8 +12,11 @@ use std::{ io::{self, ErrorKind}, path::{Path, PathBuf}, process::{Command, Stdio}, - sync::atomic::Ordering::Relaxed, - time::Duration, + sync::{ + atomic::{AtomicU64, Ordering::Relaxed}, + Arc, + }, + time::{Duration, Instant}, }; use wait_timeout::ChildExt; @@ -42,6 +45,8 @@ fn _main() -> io::Result<()> { .collect::, io::Error>>()?; test_cases.sort_unstable(); + let total_vim_time = Arc::new(AtomicU64::new(0)); + let html_conversion = test_cases .par_iter() .filter(|f| f.extension() == Some(OsStr::new("just"))) @@ -56,6 +61,8 @@ fn _main() -> io::Result<()> { let output = tempdir.path().join(format!("{}.output.html", name)); + let ts = Instant::now(); + let mut vim = Command::new("vim") .args(["--not-a-term", "-S", "convert-to-html.vim"]) .env("CASE", case) @@ -92,6 +99,9 @@ fn _main() -> io::Result<()> { )); } + let vim_time = ts.elapsed().as_millis() as u64; + total_vim_time.fetch_add(vim_time, Relaxed); + let html = Html::parse_document(&fs::read_to_string(&output).unwrap()); let code_element_selector = Selector::parse("#vimCodeElement").unwrap(); @@ -110,6 +120,11 @@ fn _main() -> io::Result<()> { Err(e) => return Err(e), }; + eprintln!( + "Vim total execution time: {}s.", + total_vim_time.load(Relaxed) as f64 / 1000.0 + ); + for case in test_cases .iter() .filter(|f| f.extension() == Some(OsStr::new("just")))