1
0
Fork 0

Benchmark resource preview generator with a verbose print

This commit is contained in:
Yuri Sizov 2024-01-26 18:55:27 +01:00
parent 99ac3d332a
commit c848bfc1bb
1 changed files with 10 additions and 0 deletions

View File

@ -129,6 +129,8 @@ void EditorResourcePreview::_preview_ready(const String &p_path, int p_hash, con
void EditorResourcePreview::_generate_preview(Ref<ImageTexture> &r_texture, Ref<ImageTexture> &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<ImageTexture> &r_texture, Ref<
if (type.is_empty()) {
r_texture = Ref<ImageTexture>();
r_small_texture = Ref<ImageTexture>();
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<ImageTexture> &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 {