From 445505ada572fbf7be3ce474a1af31419ff68c2b Mon Sep 17 00:00:00 2001 From: Paweł Redman Date: Thu, 12 Apr 2018 22:51:20 +0200 Subject: Better game timing and better FPS/TPS display. --- src/common.hpp | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'src/common.hpp') diff --git a/src/common.hpp b/src/common.hpp index 1cd1921..bb95f0e 100644 --- a/src/common.hpp +++ b/src/common.hpp @@ -40,6 +40,27 @@ extern bool debug_AI; typedef uint64_t ntime_t; ntime_t nclock(void); +class freq_counter_t { + ntime_t *samples; + size_t num_samples, collected = 0; + ntime_t last_tick = 0; + + float last_ma; + ntime_t last_ma_time = 0; + + void push(ntime_t sample); + +public: + freq_counter_t(size_t num_samples_); + ~freq_counter_t(void); + + void tick(void); + float freq_ma(void); +}; + +extern freq_counter_t fc_render; +extern freq_counter_t fc_game; + namespace procgen { class prng_t { uint32_t state = 0; @@ -351,9 +372,6 @@ namespace interface { std::list log; - double perf_hist[10] = {0}; - size_t perf_hist_index = 0; - void start_following(void); void stop_following(void); -- cgit