summaryrefslogtreecommitdiffhomepage
path: root/shaders
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2023-08-30 18:38:03 +0200
committerStanislaw Halik <sthalik@misaki.pl>2023-08-30 18:40:16 +0200
commitf528908f599a7bc551923c681c6cbd5535c5e767 (patch)
treec54b985606c15b431e3425da43d7a7fd0e9cef2b /shaders
parent4ad81e683a72337cd170ebef532ddaa08c2818e2 (diff)
shaders: move tuc stats timer to tuc
Diffstat (limited to 'shaders')
-rw-r--r--shaders/texture-unit-cache.cpp31
1 files changed, 20 insertions, 11 deletions
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 <cstdio>
+#include <chrono>
#include <Corrade/Containers/String.h>
#include <Magnum/GL/Texture.h>
@@ -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()