author | unC0Rr |
Sat, 18 Jan 2025 16:57:26 +0100 | |
changeset 16058 | de01be16df95 |
parent 16051 | a5eaeefa4ab3 |
permissions | -rw-r--r-- |
16051 | 1 |
use criterion::{black_box, criterion_group, criterion_main, Criterion}; |
2 |
use integral_geometry::{Point, Rect, Size}; |
|
3 |
use landgen; |
|
4 |
use landgen::outline_template_based::outline_template::OutlineTemplate; |
|
5 |
use landgen::outline_template_based::template_based::TemplatedLandGenerator; |
|
16058
de01be16df95
Make slider below preview affect WFC generator by skewing tile probabilities
unC0Rr
parents:
16051
diff
changeset
|
6 |
use landgen::{LandGenerationParameters, LandGenerator}; |
16051 | 7 |
|
8 |
pub fn generate_outline(c: &mut Criterion) { |
|
9 |
let template = OutlineTemplate { |
|
16058
de01be16df95
Make slider below preview affect WFC generator by skewing tile probabilities
unC0Rr
parents:
16051
diff
changeset
|
10 |
islands: vec![ |
de01be16df95
Make slider below preview affect WFC generator by skewing tile probabilities
unC0Rr
parents:
16051
diff
changeset
|
11 |
vec![ |
de01be16df95
Make slider below preview affect WFC generator by skewing tile probabilities
unC0Rr
parents:
16051
diff
changeset
|
12 |
Rect::from_box(273, 273, 2048, 2048), |
de01be16df95
Make slider below preview affect WFC generator by skewing tile probabilities
unC0Rr
parents:
16051
diff
changeset
|
13 |
Rect::from_box(683, 683, 32, 63), |
de01be16df95
Make slider below preview affect WFC generator by skewing tile probabilities
unC0Rr
parents:
16051
diff
changeset
|
14 |
Rect::from_box(1092, 1092, 2048, 2048), |
de01be16df95
Make slider below preview affect WFC generator by skewing tile probabilities
unC0Rr
parents:
16051
diff
changeset
|
15 |
], |
de01be16df95
Make slider below preview affect WFC generator by skewing tile probabilities
unC0Rr
parents:
16051
diff
changeset
|
16 |
vec![ |
de01be16df95
Make slider below preview affect WFC generator by skewing tile probabilities
unC0Rr
parents:
16051
diff
changeset
|
17 |
Rect::from_box(1638, 1638, 2048, 2048), |
de01be16df95
Make slider below preview affect WFC generator by skewing tile probabilities
unC0Rr
parents:
16051
diff
changeset
|
18 |
Rect::from_box(2048, 2048, 32, 63), |
de01be16df95
Make slider below preview affect WFC generator by skewing tile probabilities
unC0Rr
parents:
16051
diff
changeset
|
19 |
Rect::from_box(2458, 2458, 2048, 2048), |
de01be16df95
Make slider below preview affect WFC generator by skewing tile probabilities
unC0Rr
parents:
16051
diff
changeset
|
20 |
], |
de01be16df95
Make slider below preview affect WFC generator by skewing tile probabilities
unC0Rr
parents:
16051
diff
changeset
|
21 |
vec![ |
de01be16df95
Make slider below preview affect WFC generator by skewing tile probabilities
unC0Rr
parents:
16051
diff
changeset
|
22 |
Rect::from_box(3004, 3004, 2048, 2048), |
de01be16df95
Make slider below preview affect WFC generator by skewing tile probabilities
unC0Rr
parents:
16051
diff
changeset
|
23 |
Rect::from_box(3413, 3413, 32, 63), |
de01be16df95
Make slider below preview affect WFC generator by skewing tile probabilities
unC0Rr
parents:
16051
diff
changeset
|
24 |
Rect::from_box(3823, 3823, 2048, 2048), |
de01be16df95
Make slider below preview affect WFC generator by skewing tile probabilities
unC0Rr
parents:
16051
diff
changeset
|
25 |
], |
16051 | 26 |
], |
16058
de01be16df95
Make slider below preview affect WFC generator by skewing tile probabilities
unC0Rr
parents:
16051
diff
changeset
|
27 |
walls: vec![], |
de01be16df95
Make slider below preview affect WFC generator by skewing tile probabilities
unC0Rr
parents:
16051
diff
changeset
|
28 |
fill_points: vec![Point::new(1, 0)], |
de01be16df95
Make slider below preview affect WFC generator by skewing tile probabilities
unC0Rr
parents:
16051
diff
changeset
|
29 |
size: Size { |
de01be16df95
Make slider below preview affect WFC generator by skewing tile probabilities
unC0Rr
parents:
16051
diff
changeset
|
30 |
width: 4096, |
de01be16df95
Make slider below preview affect WFC generator by skewing tile probabilities
unC0Rr
parents:
16051
diff
changeset
|
31 |
height: 2048, |
de01be16df95
Make slider below preview affect WFC generator by skewing tile probabilities
unC0Rr
parents:
16051
diff
changeset
|
32 |
}, |
de01be16df95
Make slider below preview affect WFC generator by skewing tile probabilities
unC0Rr
parents:
16051
diff
changeset
|
33 |
can_flip: false, |
de01be16df95
Make slider below preview affect WFC generator by skewing tile probabilities
unC0Rr
parents:
16051
diff
changeset
|
34 |
can_invert: false, |
de01be16df95
Make slider below preview affect WFC generator by skewing tile probabilities
unC0Rr
parents:
16051
diff
changeset
|
35 |
can_mirror: false, |
de01be16df95
Make slider below preview affect WFC generator by skewing tile probabilities
unC0Rr
parents:
16051
diff
changeset
|
36 |
is_negative: false, |
de01be16df95
Make slider below preview affect WFC generator by skewing tile probabilities
unC0Rr
parents:
16051
diff
changeset
|
37 |
}; |
16051 | 38 |
|
16058
de01be16df95
Make slider below preview affect WFC generator by skewing tile probabilities
unC0Rr
parents:
16051
diff
changeset
|
39 |
let parameters = LandGenerationParameters::new(0u16, 32768u16, 10, false, false); |
16051 | 40 |
|
16058
de01be16df95
Make slider below preview affect WFC generator by skewing tile probabilities
unC0Rr
parents:
16051
diff
changeset
|
41 |
c.bench_function("outline_generation", |b| { |
de01be16df95
Make slider below preview affect WFC generator by skewing tile probabilities
unC0Rr
parents:
16051
diff
changeset
|
42 |
b.iter(|| { |
de01be16df95
Make slider below preview affect WFC generator by skewing tile probabilities
unC0Rr
parents:
16051
diff
changeset
|
43 |
fn prng() -> impl Iterator<Item = u32> { |
de01be16df95
Make slider below preview affect WFC generator by skewing tile probabilities
unC0Rr
parents:
16051
diff
changeset
|
44 |
(0..).map(|i| (i as u64 * 31_234_773 % 2_017_234_567) as u32) |
de01be16df95
Make slider below preview affect WFC generator by skewing tile probabilities
unC0Rr
parents:
16051
diff
changeset
|
45 |
} |
16051 | 46 |
|
16058
de01be16df95
Make slider below preview affect WFC generator by skewing tile probabilities
unC0Rr
parents:
16051
diff
changeset
|
47 |
let gen = TemplatedLandGenerator::new(black_box(template.clone())); |
de01be16df95
Make slider below preview affect WFC generator by skewing tile probabilities
unC0Rr
parents:
16051
diff
changeset
|
48 |
gen.generate_land(black_box(¶meters), &mut prng()) |
de01be16df95
Make slider below preview affect WFC generator by skewing tile probabilities
unC0Rr
parents:
16051
diff
changeset
|
49 |
}) |
de01be16df95
Make slider below preview affect WFC generator by skewing tile probabilities
unC0Rr
parents:
16051
diff
changeset
|
50 |
}); |
16051 | 51 |
} |
52 |
||
53 |
criterion_group!(benches, generate_outline); |
|
54 |
criterion_main!(benches); |