From 670f3864e08003b89a362f381a12d509611db870 Mon Sep 17 00:00:00 2001 From: Rory Dudley Date: Mon, 19 Feb 2024 01:04:17 -0700 Subject: Refresh paths every loop Implements the path refresh at the start of each REPL loop. On this commit, it is printing out how long it needed to refresh all the paths in milliseconds. --- src/main.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index 7fc8991..272eec1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,18 +4,21 @@ use std::io; use std::io::Write; use std::path::Path; use std::process::Command; +use std::time::SystemTime; fn eval(paths: &[&str], prompt: &str) { let mut bins: Vec = Vec::new(); - for path in paths { - let files = fs::read_dir(path).expect("Unable to read files in your path"); - for file in files { - bins.push(file.unwrap().path().display().to_string()); + loop { + let now = SystemTime::now(); + for path in paths { + let files = fs::read_dir(path).expect("Unable to read files in your path"); + for file in files { + bins.push(file.unwrap().path().display().to_string()); + } } - } + println!("Refresh: {} ms", now.elapsed().unwrap().as_millis()); - loop { // Output the prompt io::stdout().flush().unwrap(); print!("{}", prompt); -- cgit v1.2.3