Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@torkleyy
Last active March 25, 2018 20:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save torkleyy/c0b90863f61198e3563a39e860208c6b to your computer and use it in GitHub Desktop.
Save torkleyy/c0b90863f61198e3563a39e860208c6b to your computer and use it in GitHub Desktop.
Specs System Decorator
use specs::System;
use specs::SystemData;
pub struct InstrumentedSystem<T> {
pub system: T,
}
impl<T> InstrumentedSystem<T> {
pub fn new(system: T) -> Self {
InstrumentedSystem {
system,
}
}
}
impl<'a, T> System<'a> for InstrumentedSystem<T>
where
T: for<'b> System<'b>,
{
type SystemData = <T as System<'a>::SystemData;
fn run(&mut self, data: Self::SystemData) {
self.system.run(data);
// TODO Measure execution time etc.
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment