Use 128 bit math for InterpolateOffset
We were being lazy with InterpolateOffset and using the first point as
the integer part of the result, and putting all of the error in the
double. That gets imprecise when we extrapolate long distances, which
is common at the start of log files.
Instead, use the exact integer math, and use the double to capture the
remainder. This is significantly more precise, since we should never
see values over 1.0 in the double.
Change-Id: I02bf511239cd20dbff7d17327db2f665c6aa41d3
Signed-off-by: Austin Schuh <austin.linux@gmail.com>
diff --git a/aos/events/logging/boot_timestamp.h b/aos/events/logging/boot_timestamp.h
index d0fde73..e818fb9 100644
--- a/aos/events/logging/boot_timestamp.h
+++ b/aos/events/logging/boot_timestamp.h
@@ -4,6 +4,7 @@
#include <iostream>
#include "aos/time/time.h"
+#include "glog/logging.h"
namespace aos::logger {
@@ -24,6 +25,18 @@
return {boot, duration - d};
}
+ BootDuration operator-(BootDuration d) const {
+ CHECK_EQ(d.boot, boot);
+ return {boot, duration - d.duration};
+ }
+
+ BootDuration operator+(BootDuration d) const {
+ CHECK_EQ(d.boot, boot);
+ return {boot, duration + d.duration};
+ }
+
+ BootDuration operator/(int x) const { return {boot, duration / x}; }
+
bool operator==(const BootDuration &m2) const {
return boot == m2.boot && duration == m2.duration;
}