Last active
March 25, 2018 20:35
-
-
Save torkleyy/c0b90863f61198e3563a39e860208c6b to your computer and use it in GitHub Desktop.
Specs System Decorator
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
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