Sfoglia il codice sorgente

make perft print time, nodes and nps

Nicolas Winkler 2 anni fa
parent
commit
ba882da37a
1 ha cambiato i file con 14 aggiunte e 2 eliminazioni
  1. 14 2
      src/engine.rs

+ 14 - 2
src/engine.rs

@@ -5,7 +5,7 @@ use movegen::*;
 use std::io::BufRead;
 use std::process::exit;
 use std::sync::mpsc::{Sender, self};
-use std::time::Duration;
+use std::time::{Duration, Instant};
 use zobrist::ZobristTable;
 use std::thread;
 
@@ -191,7 +191,19 @@ impl Engine {
             if si.perft {
                 let depth = si.depth.unwrap_or(0);
                 let mut pc = SearchControl::new_perft(&self.board, rcv, depth);
-                let search_rtn = move || pc.perft(depth);
+                let search_rtn = move || {
+                    let before = Instant::now();
+                    let rv = pc.perft(depth);
+                    if !rv {
+                        let after = Instant::now();
+                        let nodes = pc.nodes;
+                        let duration = after - before;
+                        let nps = nodes / duration.as_millis() as usize * 1000;
+                        println!("finished in {} ms", duration.as_millis());
+                        println!("nodes: {} nps: {}", nodes, nps);
+                    }
+                    rv
+                };
                 thread::spawn(search_rtn)
             }
             else {