33 lines
		
	
	
	
		
			724 B
		
	
	
	
		
			Rust
		
	
	
	
	
	
			
		
		
	
	
			33 lines
		
	
	
	
		
			724 B
		
	
	
	
		
			Rust
		
	
	
	
	
	
| use criterion::{criterion_group, criterion_main, Criterion};
 | |
| 
 | |
| use factorio_pathfinding::belt_finding::brute_force::problems::{mid, simple, snake};
 | |
| 
 | |
| macro_rules! bench_bruteforce {
 | |
|     ($b:ident; $i:ident) => {
 | |
| 
 | |
|         $b.bench_function(stringify!($i), |b| {
 | |
|         let p = $i();
 | |
| 
 | |
|         b.iter(|| {
 | |
|             let mut b = p.clone();
 | |
| 
 | |
|             while b.next_finish_state(None) {}
 | |
| 
 | |
|             b.solution_count()
 | |
|         });
 | |
|     })
 | |
|     };
 | |
|     ($b:ident; $i:ident $($is:ident )+) => {
 | |
| 
 | |
|         bench_bruteforce!($b; $i);
 | |
|         bench_bruteforce!($b; $($is)+);
 | |
| 
 | |
|     };
 | |
| }
 | |
| 
 | |
| fn brute_force(c: &mut Criterion) {
 | |
|     bench_bruteforce!(c; simple mid snake);
 | |
| }
 | |
| 
 | |
| criterion_group!(benches, brute_force);
 | |
| criterion_main!(benches);
 |