Skip to content

Commit

Permalink
tests: print grand total execution time of all Vim processes
Browse files Browse the repository at this point in the history
  • Loading branch information
laniakea64 committed Nov 17, 2023
1 parent 340c840 commit 23ab377
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions tests/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -42,6 +45,8 @@ fn _main() -> io::Result<()> {
.collect::<Result<Vec<_>, 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")))
Expand All @@ -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)
Expand Down Expand Up @@ -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();
Expand All @@ -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")))
Expand Down

0 comments on commit 23ab377

Please sign in to comment.