From f528908f599a7bc551923c681c6cbd5535c5e767 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 30 Aug 2023 18:38:03 +0200 Subject: shaders: move tuc stats timer to tuc --- shaders/texture-unit-cache.cpp | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) (limited to 'shaders') diff --git a/shaders/texture-unit-cache.cpp b/shaders/texture-unit-cache.cpp index ec4a2212..69995a55 100644 --- a/shaders/texture-unit-cache.cpp +++ b/shaders/texture-unit-cache.cpp @@ -2,6 +2,7 @@ #include "compat/assert.hpp" #include +#include #include #include @@ -94,18 +95,26 @@ void texture_unit_cache::unlock(size_t i, bool reuse_immediately) void texture_unit_cache::output_stats() { - auto total = cache_hit_count + cache_miss_count; +#if 0 + using namespace std::literals; + auto total = cache_hit_count + cache_miss_count; - if (total > 0) - { - [[maybe_unused]] auto ratio = (double)cache_hit_count/(double)(cache_hit_count+cache_miss_count); - //printf("texture-binding: hit rate %.2f%% (%zu binds total)\n", ratio*100, (size_t)total); std::fflush(stdout); - } - if (total > (size_t)10'000) - { - cache_hit_count /= 5; - cache_miss_count /= 5; - } + static auto t0 = std::chrono::high_resolution_clock::now(); + auto t = std::chrono::high_resolution_clock::now(); + + if (t - t0 > 5s) [[unlikely]] + { + t0 = t; + [[maybe_unused]] auto ratio = (double)cache_hit_count/(double)(cache_hit_count+cache_miss_count); + printf("texture-binding: hit rate %.2f%% (%zu binds total)\n", ratio*100, total); + std::fflush(stdout); + } + if (total > (size_t)1e4) + { + cache_hit_count /= 9; + cache_miss_count /= 9; + } +#endif } size_t texture_unit_cache::get_unit_count() -- cgit v1.2.3