From c848bfc1bbfd869da709e36be52447c71c43ae46 Mon Sep 17 00:00:00 2001 From: Yuri Sizov Date: Fri, 26 Jan 2024 18:55:27 +0100 Subject: [PATCH] Benchmark resource preview generator with a verbose print --- editor/editor_resource_preview.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/editor/editor_resource_preview.cpp b/editor/editor_resource_preview.cpp index 1702277ebcd5..623aa3f45c7e 100644 --- a/editor/editor_resource_preview.cpp +++ b/editor/editor_resource_preview.cpp @@ -129,6 +129,8 @@ void EditorResourcePreview::_preview_ready(const String &p_path, int p_hash, con void EditorResourcePreview::_generate_preview(Ref &r_texture, Ref &r_small_texture, const QueueItem &p_item, const String &cache_base, Dictionary &p_metadata) { String type; + uint64_t started_at = OS::get_singleton()->get_ticks_usec(); + if (p_item.resource.is_valid()) { type = p_item.resource->get_class(); } else { @@ -138,6 +140,10 @@ void EditorResourcePreview::_generate_preview(Ref &r_texture, Ref< if (type.is_empty()) { r_texture = Ref(); r_small_texture = Ref(); + + if (is_print_verbose_enabled()) { + print_line(vformat("Generated '%s' preview in %d usec", p_item.path, OS::get_singleton()->get_ticks_usec() - started_at)); + } return; //could not guess type } @@ -196,6 +202,10 @@ void EditorResourcePreview::_generate_preview(Ref &r_texture, Ref< _write_preview_cache(f, thumbnail_size, has_small_texture, FileAccess::get_modified_time(p_item.path), FileAccess::get_md5(p_item.path), p_metadata); } } + + if (is_print_verbose_enabled()) { + print_line(vformat("Generated '%s' preview in %d usec", p_item.path, OS::get_singleton()->get_ticks_usec() - started_at)); + } } const Dictionary EditorResourcePreview::get_preview_metadata(const String &p_path) const {