#![feature(test)]


extern crate test;

extern crate specs_transform;
extern crate specs_bundler;
extern crate specs;


use test::Bencher;

use specs::{World, DispatcherBuilder};
use specs_bundler::SpecsBundler;


#[bench]
fn bench_specs_transform_system(b: &mut Bencher) {
    use specs_transform::{TransformBundle, Child, LocalTransform3D, Transform3D};

    let mut world = World::new();

    let mut dispatcher = SpecsBundler::new(&mut world, DispatcherBuilder::new())
        .bundle::<TransformBundle<f32>>(()).unwrap()
        .dispatcher_builder()
        .build();

    let parent = world.create_entity()
        .with(LocalTransform3D::<f32>::new())
        .with(Transform3D::<f32>::new())
        .build();

    let child = world.create_entity()
        .with(Child::new(parent))
        .with(LocalTransform3D::<f32>::new())
        .with(Transform3D::<f32>::new())
        .build();

    let _ = world.create_entity()
        .with(Child::new(child))
        .with(LocalTransform3D::<f32>::new())
        .with(Transform3D::<f32>::new())
        .build();

    b.iter(move || {
        dispatcher.dispatch(&mut world.res);
    });
}
