Add criterion benchmark

This commit is contained in:
hal8174 2023-12-31 20:49:07 +01:00
parent 9cb7e25149
commit 6c2c34f9a3
6 changed files with 520 additions and 6 deletions

View file

@ -7,7 +7,7 @@ use crate::misc::Map;
use super::{Direction, Position, COLORS};
#[derive(Default)]
#[derive(Default, Clone)]
pub struct BruteforceField {
pub blocked: bool,
underground_vertical: bool,
@ -53,6 +53,7 @@ impl PathField {
static MAX_UNDERGROUND_LENGTH: u8 = 6;
#[derive(Clone)]
pub struct BruteforceBuilder {
map: Map<BruteforceField>,
path: Vec<[(Position, Direction); 2]>,
@ -110,6 +111,7 @@ impl BruteforceBuilder {
}
}
#[derive(Clone)]
struct Problem {
path: Vec<PathField>,
end_pos: Position,
@ -117,6 +119,7 @@ struct Problem {
finished: bool,
}
#[derive(Clone)]
pub struct Bruteforce {
map: Map<BruteforceField>,
problems: Vec<Problem>,

View file

@ -119,12 +119,12 @@ where
#[cfg(test)]
mod test {
use crate::{
belt_finding::QueueObject,
graph::wheighted_graph::{
adjacency_list::WheightedAdjacencyList, shortest_path::dijkstra, WheightedGraph,
},
priority_queue::{BinaryHeap, PriorityQueue},
priority_queue::BinaryHeap,
};
#[test]

View file

@ -1,3 +1,4 @@
#[derive(Clone)]
pub struct Map<T> {
pub width: usize,
pub height: usize,