don't make so many clock_gettime syscalls
For all of the code that runs periodically for short periods of time,
making more than just 1 syscall to figure out what time it currently is
is pointless and a waste of CPU.
diff --git a/aos/common/controls/control_loop-tmpl.h b/aos/common/controls/control_loop-tmpl.h
index dde33c0..baf352b 100644
--- a/aos/common/controls/control_loop-tmpl.h
+++ b/aos/common/controls/control_loop-tmpl.h
@@ -146,8 +146,12 @@
template <class T, bool has_position, bool fail_no_position, bool fail_no_goal>
void ControlLoop<T, has_position, fail_no_position, fail_no_goal>::Run() {
+ ::aos::time::Time::EnableMockTime();
while (true) {
- time::SleepUntil(NextLoopTime());
+ ::aos::time::Time::UpdateMockTime();
+ const ::aos::time::Time next_loop = NextLoopTime();
+ time::SleepUntil(next_loop);
+ ::aos::time::Time::SetMockTime(next_loop);
Iterate();
}
}