From 8f055dfb27821fddb0fb20c142c4cfbe9e597690 Mon Sep 17 00:00:00 2001 From: Daniel Olsen Date: Sun, 16 May 2021 19:12:56 +0200 Subject: [PATCH] better logging --- Cargo.lock | 7 +++++++ Cargo.toml | 2 ++ src/main.rs | 16 ++++++++++++---- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4e1b65f..11514a9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -272,6 +272,7 @@ dependencies = [ "coz", "modular-bitfield", "rand", + "thousands", "tinyvec", ] @@ -419,6 +420,12 @@ dependencies = [ "unicode-xid", ] +[[package]] +name = "thousands" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3bf63baf9f5039dadc247375c29eb13706706cfde997d0330d05aa63a77d8820" + [[package]] name = "tinyvec" version = "1.1.0" diff --git a/Cargo.toml b/Cargo.toml index 3983d83..17fd930 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,6 +14,8 @@ tinyvec = "1.1.0" cached = "0.23.0" ahash = "0.7.2" +thousands = "0.2.0" + modular-bitfield = "0.11.2" #jemallocator = "0.3.2" diff --git a/src/main.rs b/src/main.rs index 8a6869a..f03c420 100644 --- a/src/main.rs +++ b/src/main.rs @@ -7,6 +7,8 @@ mod azul2; use azul2::*; use rand::prelude::*; +use thousands::Separable; + //#[global_allocator] //static GLOBAL: jemallocator::Jemalloc = jemallocator::Jemalloc; @@ -28,9 +30,9 @@ fn main() -> Result<(), &'static str> { game.do_move(GameMove(5, Tile::Yellow, 2))?; game.do_move(GameMove(3, Tile::Blue, 2))?; - game.do_move(GameMove(0, Tile::Black, 4))?; + //game.do_move(GameMove(0, Tile::Black, 4))?; - game.do_move(GameMove(5, Tile::Black, 1))?; + //game.do_move(GameMove(5, Tile::Black, 1))?; //game.do_move(GameMove(0, Tile::Blue, 3))?; println!("{}", count_options(game, 1, 2)); @@ -89,8 +91,10 @@ fn calculate_options() -> Result<(), &'static str> { Ok(()) } -#[cached(size=7_000_000, key = "Game", convert = r#"{ _game }"#)] +#[cached(size=45_000_000, key = "Game", convert = r#"{ _game }"#)] fn count_options(_game: Game, depth: u8, treshold: u8) -> u128 { + let before = std::time::Instant::now(); + let mut sum = 0; let mut all_failed = true; @@ -133,7 +137,11 @@ fn count_options(_game: Game, depth: u8, treshold: u8) -> u128 { } if depth <= treshold { - println!("{}: sum: {}", depth, sum); + let elapsed = before.elapsed(); + let hashrate = sum / std::cmp::max(elapsed.as_millis() as u128, 1u128) * 1000u128; + println!("{}: sum: {}, took +{:?}: {}/s", + depth, sum, elapsed, hashrate.separate_with_spaces() + ); } return sum;