-void EventBase::SmoothLoopTime::addSample(int64_t idle, int64_t busy) {
- /*
- * Position at which the busy sample is considered to be taken.
- * (Allows to quickly skew our average without editing much code)
- */
- enum BusySamplePosition {
- RIGHT = 0, // busy sample placed at the end of the iteration
- CENTER = 1, // busy sample placed at the middle point of the iteration
- LEFT = 2, // busy sample placed at the beginning of the iteration
- };
-
- VLOG(11) << "idle " << idle << " oldBusyLeftover_ " << oldBusyLeftover_ <<
- " idle + oldBusyLeftover_ " << idle + oldBusyLeftover_ <<
- " busy " << busy << " " << __PRETTY_FUNCTION__;
+void EventBase::SmoothLoopTime::addSample(
+ std::chrono::microseconds idle,
+ std::chrono::microseconds busy) {
+ /*
+ * Position at which the busy sample is considered to be taken.
+ * (Allows to quickly skew our average without editing much code)
+ */
+ enum BusySamplePosition {
+ RIGHT = 0, // busy sample placed at the end of the iteration
+ CENTER = 1, // busy sample placed at the middle point of the iteration
+ LEFT = 2, // busy sample placed at the beginning of the iteration
+ };
+
+ // See http://en.wikipedia.org/wiki/Moving_average#Exponential_moving_average
+ // and D676020 for more info on this calculation.
+ VLOG(11) << "idle " << idle.count() << " oldBusyLeftover_ "
+ << oldBusyLeftover_.count() << " idle + oldBusyLeftover_ "
+ << (idle + oldBusyLeftover_).count() << " busy " << busy.count()
+ << " " << __PRETTY_FUNCTION__;