aboutsummaryrefslogtreecommitdiff
path: root/azalea
diff options
context:
space:
mode:
authormat <git@matdoes.dev>2026-01-18 23:08:59 -0900
committermat <git@matdoes.dev>2026-01-18 23:08:59 -0900
commit70bd9c94dd7ca68777a0ead5f9432812e535bee3 (patch)
tree62b1c211792268b95a9e08c3636938a817f62af6 /azalea
parentd31574bc0967a7422bac00aeda6687ca684689d4 (diff)
downloadazalea-drasl-70bd9c94dd7ca68777a0ead5f9432812e535bee3.tar.xz
use lookup table for is_collision_shape_empty and is_collision_shape_full
Diffstat (limited to 'azalea')
-rw-r--r--azalea/benches/physics.rs31
1 files changed, 28 insertions, 3 deletions
diff --git a/azalea/benches/physics.rs b/azalea/benches/physics.rs
index a0811566..d81a0221 100644
--- a/azalea/benches/physics.rs
+++ b/azalea/benches/physics.rs
@@ -1,11 +1,15 @@
+use std::hint::black_box;
+
use azalea::{
Vec3,
pathfinder::simulation::{SimulatedPlayerBundle, SimulationSet},
};
+use azalea_block::BlockState;
use azalea_core::position::{ChunkBlockPos, ChunkPos};
+use azalea_physics::collision::BlockWithShape;
use azalea_registry::builtin::BlockKind;
use azalea_world::{Chunk, ChunkStorage, PartialChunkStorage};
-use criterion::{Bencher, Criterion, criterion_group, criterion_main};
+use criterion::{BatchSize, Bencher, Criterion, criterion_group, criterion_main};
#[allow(dead_code)]
fn generate_world(partial_chunks: &mut PartialChunkStorage, size: u32) -> ChunkStorage {
@@ -77,11 +81,32 @@ fn run_physics_benchmark(b: &mut Bencher<'_>) {
})
}
-fn bench_pathfinder(c: &mut Criterion) {
+fn bench_physics(c: &mut Criterion) {
c.bench_function("physics", |b| {
run_physics_benchmark(b);
});
+
+ c.bench_function("is_collision_shape_full", |b| {
+ b.iter_batched(
+ || {
+ let mut blocks = Vec::new();
+ for _ in 0..1024 {
+ let id = rand::random_range(0..=BlockState::MAX_STATE);
+ let block = BlockState::try_from(id).unwrap();
+ blocks.push(block);
+ }
+ blocks
+ },
+ |blocks| {
+ for block in blocks {
+ black_box(block.is_collision_shape_full());
+ // black_box(block.collision_shape() == SHAPE1);
+ }
+ },
+ BatchSize::LargeInput,
+ );
+ });
}
-criterion_group!(benches, bench_pathfinder);
+criterion_group!(benches, bench_physics);
criterion_main!(benches);