Skip to content

Commit

Permalink
Benchmark resource preview generator with a verbose print
Browse files Browse the repository at this point in the history
  • Loading branch information
YuriSizov committed Jan 26, 2024
1 parent 99ac3d3 commit c848bfc
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions editor/editor_resource_preview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
}

Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit c848bfc

Please sign in to comment.