-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbenchmark.rs
More file actions
58 lines (46 loc) · 1.7 KB
/
benchmark.rs
File metadata and controls
58 lines (46 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
use std::time::{Instant, Duration};
use crate::search::{compute_win_chance_exact, SearchResult};
use dashmap::DashMap;
use crossbeam_channel::{unbounded, RecvError};
use crate::gui::{ReportMessage, SearchMode};
use std::thread::sleep;
use crate::parsing::examples_357;
// benchmarks the algorithm on the 348 hardest puzzles using one core
// might take several minutes
pub fn benchmark()
{
println!("Benchmarking! Might take minutes or even hours...");
// One thread only
let threads = 12;
// Loading puzzles
let puzzles = examples_357();
// Search mode
let mode = SearchMode::WinEight;
// preparing cache
let cache = DashMap::with_capacity(111_744_155);
// Benchmarking
let mut total_time = 0.0;
for (nr, sr, sc, br, bc, level, _state) in puzzles
{
let (control_sender, control_receiver) = unbounded();
let (result_reporting_sender, result_reporting_receiver) = unbounded();
cache.clear();
let search_result = compute_win_chance_exact(
0, &sr, &sc, &br, &bc, level,
&cache,
&control_receiver,
&result_reporting_sender,
&control_sender, mode, threads);
if let SearchResult::SuccessfulSearchWithInfo(prob, time, nodes) = search_result
{
//println!("Puzzle {}: {} in {}s with {} nodes", nr, prob, time, nodes);
println!("{}", prob);
total_time += time;
}
}
//println!("--------------------------------------------------------------------------------");
//println!("Needed {} seconds", total_time);
loop {
sleep(Duration::from_secs(3600));
}
}