diff options
| author | mat <git@matdoes.dev> | 2026-03-18 16:28:46 -1030 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2026-03-20 04:21:58 -0200 |
| commit | 25cd1c0b60604655b70d70f8ec33a54853905eea (patch) | |
| tree | 28911045f6d69b2fffcb8d9c5a92fe32657b5e4b /azalea-protocol/benches | |
| parent | b03d2942e1bef98e13acadde5cbb8856a3f8c74d (diff) | |
| download | azalea-drasl-25cd1c0b60604655b70d70f8ec33a54853905eea.tar.xz | |
optimize pathfinder swarms and write perf guide
Diffstat (limited to 'azalea-protocol/benches')
| -rw-r--r-- | azalea-protocol/benches/read.rs | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/azalea-protocol/benches/read.rs b/azalea-protocol/benches/read.rs new file mode 100644 index 00000000..ad309bbc --- /dev/null +++ b/azalea-protocol/benches/read.rs @@ -0,0 +1,37 @@ +use std::{hint::black_box, io::Cursor}; + +use azalea_buf::AzBuf; +use azalea_core::position::Vec3i; +use azalea_protocol::packets::game::{ + ClientboundWaypoint, + c_waypoint::{ + TrackedWaypoint, WaypointData, WaypointIcon, WaypointIdentifier, WaypointOperation, + }, +}; +use criterion::{Criterion, criterion_group, criterion_main}; +use uuid::Uuid; + +fn benchmark(c: &mut Criterion) { + c.bench_function("c_waypoint", |b| { + let mut buf = Vec::new(); + ClientboundWaypoint { + operation: WaypointOperation::Update, + waypoint: TrackedWaypoint { + identifier: WaypointIdentifier::Uuid(Uuid::nil()), + icon: WaypointIcon { + style: "minecraft:default".into(), + color: None, + }, + data: WaypointData::Vec3i(Vec3i { x: 1, y: 67, z: 0 }), + }, + } + .azalea_write(&mut buf) + .unwrap(); + b.iter(|| { + black_box(ClientboundWaypoint::azalea_read(&mut Cursor::new(&buf)).unwrap()); + }); + }); +} + +criterion_group!(benches, benchmark); +criterion_main!(benches); |
