summaryrefslogtreecommitdiff
path: root/core/timer.h
diff options
context:
space:
mode:
Diffstat (limited to 'core/timer.h')
-rw-r--r--core/timer.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/core/timer.h b/core/timer.h
new file mode 100644
index 0000000..3d0a82f
--- /dev/null
+++ b/core/timer.h
@@ -0,0 +1,23 @@
+// file : core/timer.h
+// project : Salis-VM
+// author : Paul Oliver <contact@pauloliver.dev>
+//
+// Utilities to help measure time intervals and simulation speed.
+
+#pragma once
+
+struct Timer {
+ struct timespec time_start;
+ float time_delta;
+};
+
+struct TimerSPS {
+ struct Timer timer;
+ uint64_t step_start;
+ float steps_per_sec;
+};
+
+void timer_reset(struct Timer *timer);
+void timer_measure(struct Timer *timer);
+void timer_sps_reset(struct TimerSPS *timer_sps);
+void timer_sps_measure(struct TimerSPS *timer_sps);