summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--editor/draw.cpp14
-rw-r--r--shaders/texture-unit-cache.cpp31
2 files changed, 21 insertions, 24 deletions
diff --git a/editor/draw.cpp b/editor/draw.cpp
index 097a9deb..0b469380 100644
--- a/editor/draw.cpp
+++ b/editor/draw.cpp
@@ -12,7 +12,6 @@
#include "rotation.inl"
#include "src/RTree-search.hpp"
-#include <chrono>
#include <Magnum/Math/Color.h>
#include <Magnum/Math/Vector3.h>
#include <Magnum/GL/Renderer.h>
@@ -195,18 +194,7 @@ void app::draw()
draw_ui();
render_menu();
- using namespace std::chrono_literals;
- {
- constexpr auto print_every = 4s;
-
- static auto t0 = std::chrono::high_resolution_clock::now();
- auto t = std::chrono::high_resolution_clock::now();
- if (t - t0 >= print_every)
- {
- t0 = t;
- M->texture_unit_cache().output_stats();
- }
- }
+ M->texture_unit_cache().output_stats();
}
clickable* app::find_clickable_scenery(const Optional<Vector2i>& pixel)
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()