better logging
This commit is contained in:
		
							parent
							
								
									2435458e15
								
							
						
					
					
						commit
						8f055dfb27
					
				
							
								
								
									
										7
									
								
								Cargo.lock
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										7
									
								
								Cargo.lock
									
									
									
										generated
									
									
									
								
							@ -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"
 | 
			
		||||
 | 
			
		||||
@ -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"
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										16
									
								
								src/main.rs
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								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;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user