--- /dev/null
+#include <cmath>
+#include <msp/time/units.h>
+#include "activity.h"
+
+using namespace Msp;
+
+Activity::Activity():
+ average(0)
+{ }
+
+void Activity::add_bytes(unsigned n)
+{
+ // Scale for correct integral
+ average += n*0.06935;
+}
+
+void Activity::tick(const Time::TimeDelta &dt)
+{
+ static Time::TimeDelta last_dt;
+ static float decay = 0;
+
+ if(dt!=last_dt)
+ {
+ // Half-life in 10 seconds
+ decay = pow(0.933f, dt/Time::sec);
+ last_dt = dt;
+ }
+
+ average *= decay;
+}