summaryrefslogtreecommitdiff
path: root/robot/hypervisor.c
diff options
context:
space:
mode:
authorlonkaars <loek@pipeframe.xyz>2022-05-26 12:42:34 +0200
committerlonkaars <loek@pipeframe.xyz>2022-05-26 12:42:34 +0200
commitf353e78916a57fe21084fe34fd80c13ae4844d32 (patch)
tree392a8d6bfccad7beb70e253ad7c1786934d5657b /robot/hypervisor.c
parent54b69efe150e1a102faafb4e214159c92abbb841 (diff)
implement info command
Diffstat (limited to 'robot/hypervisor.c')
-rw-r--r--robot/hypervisor.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/robot/hypervisor.c b/robot/hypervisor.c
index c4e7aba..0baa406 100644
--- a/robot/hypervisor.c
+++ b/robot/hypervisor.c
@@ -1,11 +1,17 @@
#include "hypervisor.h"
+#include "../shared/util.h"
#include "errcatch.h"
#include "io.h"
#include "modes.h"
#include "orangutan_shim.h"
#include "sercomm.h"
-uint64_t g_w2_hypervisor_cycles = 0;
+uint64_t g_w2_hypervisor_cycles = 0;
+uint64_t g_w2_hypervisor_uptime_ms = 0;
+unsigned long g_w2_hypervisor_ema_sercomm_ms = 0;
+unsigned long g_w2_hypervisor_ema_errcatch_ms = 0;
+unsigned long g_w2_hypervisor_ema_io_ms = 0;
+unsigned long g_w2_hypervisor_ema_mode_ms = 0;
void w2_hypervisor_main() {
#ifdef W2_SIM
@@ -13,6 +19,7 @@ void w2_hypervisor_main() {
if (DBG_ENABLE_CYCLEINFO) siminfo("cycle start\n");
#endif
+ g_w2_hypervisor_uptime_ms += get_ms();
time_reset();
w2_sercomm_main();
@@ -24,6 +31,14 @@ void w2_hypervisor_main() {
w2_modes_main();
unsigned long mode_time = get_ms() - io_time;
+ // calculate exponential moving averages
+ g_w2_hypervisor_ema_sercomm_ms =
+ w2_util_exp_mov_avg(g_w2_hypervisor_ema_sercomm_ms, sercomm_time);
+ g_w2_hypervisor_ema_errcatch_ms =
+ w2_util_exp_mov_avg(g_w2_hypervisor_ema_errcatch_ms, errcatch_time);
+ g_w2_hypervisor_ema_io_ms = w2_util_exp_mov_avg(g_w2_hypervisor_ema_io_ms, io_time);
+ g_w2_hypervisor_ema_mode_ms = w2_util_exp_mov_avg(g_w2_hypervisor_ema_mode_ms, mode_time);
+
if (mode_time > W2_MAX_MODULE_CYCLE_MS) w2_errcatch_throw(W2_E_WARN_CYCLE_EXPIRED);
#ifdef W2_SIM