-
-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## Description Adds a benchmark to measure the duration of a whole server tick. Also added `bevy_ecs` to `valence::prelude`. ## Test Plan Steps: 1. `cargo bench idle_update`
- Loading branch information
Showing
4 changed files
with
46 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
use criterion::Criterion; | ||
use valence::prelude::*; | ||
|
||
/// Benches the performance of a single server tick while nothing much is | ||
/// happening. | ||
pub fn idle_update(c: &mut Criterion) { | ||
let mut app = App::new(); | ||
|
||
app.add_plugins(DefaultPlugins); | ||
app.add_startup_system(setup); | ||
|
||
// Run startup schedule. | ||
app.update(); | ||
|
||
c.bench_function("idle_update", |b| { | ||
b.iter(|| { | ||
app.update(); | ||
}); | ||
}); | ||
} | ||
|
||
fn setup( | ||
mut commands: Commands, | ||
dimensions: Query<&DimensionType>, | ||
biomes: Query<&Biome>, | ||
server: Res<Server>, | ||
) { | ||
let mut instance = Instance::new(ident!("overworld"), &dimensions, &biomes, &server); | ||
|
||
for z in -5..5 { | ||
for x in -5..5 { | ||
instance.insert_chunk([x, z], Chunk::default()); | ||
} | ||
} | ||
|
||
for z in -50..50 { | ||
for x in -50..50 { | ||
instance.set_block([x, 64, z], BlockState::GRASS_BLOCK); | ||
} | ||
} | ||
|
||
commands.spawn(instance); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters