소스 검색

added timer to flex on how fast it is to cli command.

UMTS at Teleco 2 주 전
부모
커밋
6cd20735eb
1개의 변경된 파일10개의 추가작업 그리고 1개의 파일을 삭제
  1. 10 1
      src/output.rs

+ 10 - 1
src/output.rs

@@ -201,9 +201,18 @@ pub fn print_errors(results: &[DomainResult], verbose: bool) {
 }
 
 pub fn print_progress(current: usize, total: usize) {
+    use std::sync::Mutex;
+    use std::time::Instant;
+    static START: Mutex<Option<Instant>> = Mutex::new(None);
+
+    let mut lock = START.lock().unwrap();
+    let start = *lock.get_or_insert_with(Instant::now);
+
     let percent = (current as f64 / total as f64 * 100.0) as u32;
     eprint!("\rParsing results : {}%", percent);
     if current == total {
-        eprintln!("\rParsing results : Done   ");
+        let secs = start.elapsed().as_secs_f64();
+        eprintln!("\rParsing results : Done (Took {:.1}s)   ", secs);
+        *lock = None; // reset for next search duh
     }
 }