This repository was archived by the owner on Nov 27, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 33
Added planck_ecs. Added violin graphs. #18
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
4e97396
add planck_ecs benchmarks.
AnneKitsune 31b3c08
fix benchmarks planck_ecs.
AnneKitsune ab54d55
run benchmark.
AnneKitsune c0a1d64
add report images.
AnneKitsune 74d6817
fix violin images.
AnneKitsune 980f9fb
update readme to add planck_ecs. bump planck_ecs version.
AnneKitsune 253fe01
add benchmark results.
AnneKitsune 2d71d35
Moved pictures to their own sections.
AnneKitsune 58d586a
added both serialize plots.
AnneKitsune c928ca5
Revert "added both serialize plots."
AnneKitsune e633b47
remove target before merge
AnneKitsune 727ef51
Merge branch 'master' of https://github.com/rust-gamedev/ecs_bench_su…
AnneKitsune 60c6229
run benchmarks.
AnneKitsune 38a2107
Revert "Revert "added both serialize plots.""
AnneKitsune File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,33 @@ | ||
use planck_ecs::*; | ||
struct A(f32); | ||
struct B(f32); | ||
|
||
pub struct Benchmark(Vec<Entity>, Components<A>, Components<B>); | ||
|
||
impl Benchmark { | ||
pub fn new() -> Self { | ||
let mut entities = Entities::default(); | ||
let mut comp1 = Components::<A>::default(); | ||
let comp2 = Components::<B>::default(); | ||
|
||
let entities = (0..10000) | ||
.map(|_| { | ||
let e = entities.create(); | ||
comp1.insert(e, A(0.0)); | ||
e | ||
}) | ||
.collect(); | ||
Self(entities, comp1, comp2) | ||
} | ||
|
||
pub fn run(&mut self) { | ||
let b_storage = &mut self.2; | ||
for entity in &self.0 { | ||
b_storage.insert(*entity, B(0.0)); | ||
} | ||
|
||
for entity in &self.0 { | ||
b_storage.remove(*entity); | ||
} | ||
} | ||
} |
This file contains hidden or 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,41 @@ | ||
use planck_ecs::*; | ||
|
||
macro_rules! create_entities { | ||
($world:ident; $( $variants:ident ),*) => { | ||
$( | ||
struct $variants(f32); | ||
$world.initialize::<Components<$variants>>(); | ||
(0..20) | ||
.for_each(|_| { | ||
let e = $world.get_mut::<Entities>().unwrap().create(); | ||
$world.get_mut::<Components<_>>().unwrap().insert(e, $variants(0.0)); | ||
$world.get_mut::<Components<_>>().unwrap().insert(e, Data(1.0)); | ||
}); | ||
)* | ||
}; | ||
} | ||
struct Data(f32); | ||
|
||
fn frag_iter_system(data_storage: &mut Components<Data>) -> SystemResult { | ||
for data in join!(&mut data_storage) { | ||
data.0 *= 2.0; | ||
} | ||
Ok(()) | ||
} | ||
|
||
pub struct Benchmark(World, System); | ||
|
||
impl Benchmark { | ||
pub fn new() -> Self { | ||
let mut world = World::default(); | ||
world.initialize::<Entities>(); | ||
world.initialize::<Components<Data>>(); | ||
create_entities!(world; A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z); | ||
|
||
Self(world, frag_iter_system.system()) | ||
} | ||
|
||
pub fn run(&mut self) { | ||
self.1.run(&self.0).unwrap(); | ||
} | ||
} |
This file contains hidden or 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,7 @@ | ||
pub mod add_remove; | ||
pub mod frag_iter; | ||
// We don't have inner parallelism, only outer. | ||
//pub mod heavy_compute; | ||
pub mod schedule; | ||
pub mod simple_insert; | ||
pub mod simple_iter; |
This file contains hidden or 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,82 @@ | ||
use planck_ecs::*; | ||
struct A(f32); | ||
struct B(f32); | ||
struct C(f32); | ||
struct D(f32); | ||
struct E(f32); | ||
|
||
fn ab_system(a_store: &mut Components<A>, b_store: &mut Components<B>) -> SystemResult { | ||
for (a, b) in join!(&mut a_store && &mut b_store) { | ||
std::mem::swap(&mut a.unwrap().0, &mut b.unwrap().0); | ||
} | ||
Ok(()) | ||
} | ||
|
||
fn cd_system(c_store: &mut Components<C>, d_store: &mut Components<D>) -> SystemResult { | ||
for (c, d) in join!(&mut c_store && &mut d_store) { | ||
std::mem::swap(&mut c.unwrap().0, &mut d.unwrap().0); | ||
} | ||
Ok(()) | ||
} | ||
|
||
fn ce_system(c_store: &mut Components<C>, e_store: &mut Components<E>) -> SystemResult { | ||
for (c, e) in join!(&mut c_store && &mut e_store) { | ||
std::mem::swap(&mut c.unwrap().0, &mut e.unwrap().0); | ||
} | ||
Ok(()) | ||
} | ||
|
||
pub struct Benchmark(World, Dispatcher); | ||
|
||
impl Benchmark { | ||
pub fn new() -> Self { | ||
let mut world = World::default(); | ||
world.initialize::<Entities>(); | ||
world.initialize::<Components<A>>(); | ||
world.initialize::<Components<B>>(); | ||
world.initialize::<Components<C>>(); | ||
world.initialize::<Components<D>>(); | ||
world.initialize::<Components<E>>(); | ||
(0..10000).for_each(|_| { | ||
let e = world.get_mut::<Entities>().unwrap().create(); | ||
world.get_mut::<Components<_>>().unwrap().insert(e, A(0.0)); | ||
}); | ||
(0..10000).for_each(|_| { | ||
let e = world.get_mut::<Entities>().unwrap().create(); | ||
world.get_mut::<Components<_>>().unwrap().insert(e, A(0.0)); | ||
world.get_mut::<Components<_>>().unwrap().insert(e, B(0.0)); | ||
}); | ||
(0..10000).for_each(|_| { | ||
let e = world.get_mut::<Entities>().unwrap().create(); | ||
world.get_mut::<Components<_>>().unwrap().insert(e, A(0.0)); | ||
world.get_mut::<Components<_>>().unwrap().insert(e, B(0.0)); | ||
world.get_mut::<Components<_>>().unwrap().insert(e, C(0.0)); | ||
}); | ||
(0..10000).for_each(|_| { | ||
let e = world.get_mut::<Entities>().unwrap().create(); | ||
world.get_mut::<Components<_>>().unwrap().insert(e, A(0.0)); | ||
world.get_mut::<Components<_>>().unwrap().insert(e, B(0.0)); | ||
world.get_mut::<Components<_>>().unwrap().insert(e, C(0.0)); | ||
world.get_mut::<Components<_>>().unwrap().insert(e, D(0.0)); | ||
}); | ||
(0..10000).for_each(|_| { | ||
let e = world.get_mut::<Entities>().unwrap().create(); | ||
world.get_mut::<Components<_>>().unwrap().insert(e, A(0.0)); | ||
world.get_mut::<Components<_>>().unwrap().insert(e, B(0.0)); | ||
world.get_mut::<Components<_>>().unwrap().insert(e, C(0.0)); | ||
world.get_mut::<Components<_>>().unwrap().insert(e, E(0.0)); | ||
}); | ||
|
||
let dispatcher = DispatcherBuilder::new() | ||
.add(ab_system) | ||
.add(cd_system) | ||
.add(ce_system) | ||
.build(&mut world); | ||
|
||
Self(world, dispatcher) | ||
} | ||
|
||
pub fn run(&mut self) { | ||
self.1.run_par(&self.0).unwrap(); | ||
} | ||
} |
This file contains hidden or 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,41 @@ | ||
use cgmath::*; | ||
use planck_ecs::*; | ||
|
||
#[derive(Copy, Clone)] | ||
struct Transform(Matrix4<f32>); | ||
#[derive(Copy, Clone)] | ||
struct Position(Vector3<f32>); | ||
#[derive(Copy, Clone)] | ||
struct Rotation(Vector3<f32>); | ||
#[derive(Copy, Clone)] | ||
struct Velocity(Vector3<f32>); | ||
|
||
pub struct Benchmark; | ||
|
||
impl Benchmark { | ||
pub fn new() -> Self { | ||
Self | ||
} | ||
|
||
pub fn run(&mut self) { | ||
let mut entities = Entities::default(); | ||
let mut comp1 = Components::<Transform>::default(); | ||
let mut comp2 = Components::<Position>::default(); | ||
let mut comp3 = Components::<Rotation>::default(); | ||
let mut comp4 = Components::<Velocity>::default(); | ||
|
||
let en = (0..10000).map(|_| entities.create()).collect::<Vec<_>>(); | ||
en.iter().for_each(|e| {comp1.insert(*e, Transform(Matrix4::<f32>::from_scale(1.0)));}); | ||
en.iter().for_each(|e| {comp2.insert(*e, Position(Vector3::unit_x()));}); | ||
en.iter().for_each(|e| {comp3.insert(*e, Rotation(Vector3::unit_x()));}); | ||
en.iter().for_each(|e| {comp4.insert(*e, Velocity(Vector3::unit_x()));}); | ||
|
||
/*(0..10000).for_each(|_| { | ||
let e = entities.create(); | ||
comp1.insert(e, Transform(Matrix4::<f32>::from_scale(1.0))); | ||
comp2.insert(e, Position(Vector3::unit_x())); | ||
comp3.insert(e, Rotation(Vector3::unit_x())); | ||
comp4.insert(e, Velocity(Vector3::unit_x())); | ||
});*/ | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.