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/time.h b/aos/common/time.h
index 1dc1def..846366c 100644
--- a/aos/common/time.h
+++ b/aos/common/time.h
@@ -10,6 +10,7 @@
 #include <ostream>
 
 #include "aos/common/type_traits.h"
+#include "aos/common/macros.h"
 
 namespace aos {
 namespace time {
@@ -206,7 +207,9 @@
   // Enables returning the mock time value for Now instead of checking the
   // system clock.  This should only be used when testing things depending on
   // time, or many things may/will break.
-  static void EnableMockTime(const Time &now);
+  static void EnableMockTime(const Time &now = Now());
+  // Calls SetMockTime with the current actual time.
+  static void UpdateMockTime();
   // Sets now when time is being mocked.
   static void SetMockTime(const Time &now);
   // Convenience function to just increment the mock time by a certain amount in
@@ -239,6 +242,21 @@
 // Sleeps until clock is at the time represented by time.
 void SleepUntil(const Time &time, clockid_t clock = Time::kDefaultClock);
 
+// RAII class that freezes Time::Now() (to avoid making large numbers of
+// syscalls to find the real time).
+class TimeFreezer {
+ public:
+  TimeFreezer() {
+    Time::EnableMockTime();
+  }
+  ~TimeFreezer() {
+    Time::DisableMockTime();
+  }
+
+ private:
+  DISALLOW_COPY_AND_ASSIGN(TimeFreezer);
+};
+
 }  // namespace time
 }  // namespace aos