959 } |
959 } |
960 |
960 |
961 /// Data `U` with production time attached |
961 /// Data `U` with production time attached |
962 #[derive(Copy, Clone, Debug, Serialize)] |
962 #[derive(Copy, Clone, Debug, Serialize)] |
963 pub struct Timed<U> { |
963 pub struct Timed<U> { |
|
964 /// CPU time taken |
964 pub cpu_time : Duration, |
965 pub cpu_time : Duration, |
|
966 /// Iteration number |
|
967 pub iter : usize, |
|
968 /// User data |
965 //#[serde(flatten)] |
969 //#[serde(flatten)] |
966 pub data : U |
970 pub data : U |
967 } |
971 } |
968 |
972 |
969 impl<T> LogRepr for Timed<T> where T : LogRepr { |
973 impl<T> LogRepr for Timed<T> where T : LogRepr { |
1009 fn poststep<E>(&mut self, res : Step<Self::Input, Self::State, E>) -> Step<Self::Output, Self::State, E> where E : Error { |
1013 fn poststep<E>(&mut self, res : Step<Self::Input, Self::State, E>) -> Step<Self::Output, Self::State, E> where E : Error { |
1010 match self.base_iterator.poststep(res) { |
1014 match self.base_iterator.poststep(res) { |
1011 Step::Result(data, state) => { |
1015 Step::Result(data, state) => { |
1012 Step::Result(Timed{ |
1016 Step::Result(Timed{ |
1013 cpu_time : self.start_time.elapsed(), |
1017 cpu_time : self.start_time.elapsed(), |
|
1018 iter : self.iteration(), |
1014 data |
1019 data |
1015 }, state) |
1020 }, state) |
1016 }, |
1021 }, |
1017 Step::Quiet => Step::Quiet, |
1022 Step::Quiet => Step::Quiet, |
1018 Step::Terminated => Step::Terminated, |
1023 Step::Terminated => Step::Terminated, |