Skip to content
Permalink
Browse files

remove Instant::now to use with wasm target

  • Loading branch information...
tsionyx committed May 6, 2019
1 parent 0fa1e5e commit 47b48109927e3146455636df2c32efc44232733b
Showing with 36 additions and 36 deletions.
  1. +12 −11 src/solver/backtracking.rs
  2. +8 −8 src/solver/probing.rs
  3. +16 −17 src/solver/propagation.rs
@@ -242,7 +242,7 @@ where
return Ok(());
}

self.start_time = Some(Instant::now());
//self.start_time = Some(Instant::now());

let directions = self.choose_directions(&impact);
warn!(
@@ -251,22 +251,23 @@ where
);
self.search(&directions, &[])?;

let total_time = self
.start_time
.expect("Start time should be set in current function")
.elapsed();
warn!(
"Search completed (depth reached: {}, solutions found: {})",
self.depth_reached,
self.solutions.len()
);

warn!(
"Full solution: {}.{:06} sec. The rate is {:.4}",
total_time.as_secs(),
total_time.subsec_micros(),
self.board().solution_rate(),
);
if let Some(start_time) = self.start_time {
//.expect("Start time should be set in current function")
let total_time = start_time.elapsed();

warn!(
"Full solution: {}.{:06} sec. The rate is {:.4}",
total_time.as_secs(),
total_time.subsec_micros(),
self.board().solution_rate(),
);
}

Ok(())
}
@@ -5,7 +5,7 @@ use super::propagation;

use std::cell::{Ref, RefCell};
use std::rc::Rc;
use std::time::Instant;
//use std::time::Instant;

use hashbrown::hash_map::DefaultHashBuilder;
use hashbrown::HashMap;
@@ -108,7 +108,7 @@ where
where
S: LineSolver<BlockType = B>,
{
let start = Instant::now();
//let start = Instant::now();
let mut contradictions_number = 0;
//let mut iteration_probes = HashSet::new();

@@ -176,13 +176,13 @@ where
}
};

let total_time = start.elapsed();
if contradictions_number > 0 {
warn!(
"Full solution: {}.{:06} sec",
total_time.as_secs(),
total_time.subsec_micros()
);
//let total_time = start.elapsed();
//warn!(
// "Full solution: {}.{:06} sec",
// total_time.as_secs(),
// total_time.subsec_micros()
//);
warn!("Contradictions found: {}", contradictions_number);
}
Ok(impact)
@@ -4,7 +4,7 @@ use super::line::LineSolver;

use std::cell::RefCell;
use std::rc::Rc;
use std::time::Instant;
//use std::time::Instant;

use hashbrown::HashSet;
use log::Level;
@@ -146,7 +146,7 @@ where
S: LineSolver<BlockType = B>,
Q: JobQueue,
{
let start = Instant::now();
//let start = Instant::now();
let mut lines_solved = 0_u32;
let mut solved_cells = vec![];

@@ -184,12 +184,12 @@ where
//}

if log_enabled!(Level::Info) {
let total_time = start.elapsed();
info!(
"Full solution: {}.{:06} sec",
total_time.as_secs(),
total_time.subsec_micros()
);
//let total_time = start.elapsed();
//info!(
// "Full solution: {}.{:06} sec",
// total_time.as_secs(),
// total_time.subsec_micros()
//);
info!("Lines solved: {}", lines_solved);
}
}
@@ -209,8 +209,7 @@ where
where
S: LineSolver<BlockType = B>,
{
let start = Instant::now();

//let start = Instant::now();
let (line_desc, line) = {
let board = self.board.borrow();
if is_column {
@@ -248,13 +247,13 @@ where

if log_enabled!(Level::Debug) {
let name = if is_column { "column" } else { "row" };
let total_time = start.elapsed();
debug!(
"{}s solution: {}.{:06} sec",
name,
total_time.as_secs(),
total_time.subsec_micros()
);
//let total_time = start.elapsed();
//debug!(
// "{}s solution: {}.{:06} sec",
// name,
// total_time.as_secs(),
// total_time.subsec_micros()
//);
if !indexes.is_empty() {
debug!("New info on {} {}: {:?}", name, index, indexes);
}

0 comments on commit 47b4810

Please sign in to comment.
You can’t perform that action at this time.