From edd1164575feefda103c73119a98cbd994e53141 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dietrich?= Date: Thu, 1 Oct 2020 23:16:01 +0200 Subject: Cycles: add time statistics to scene update Gathers information for time spent in the various managers or object (Film, Camera, etc.) being updated in Scene::device_update. The stats include the total time spent in the device_update methods as well as time spent in subroutines (e.g. bvh build, displacement, etc.). This does not qualify as a full blown profiler, but is useful to identify potential bottleneck areas. The stats can be enabled and printed by passing `--cycles-print-stats` on the command line to Cycles, or `-- --cycles-print-stats` to Blender. Reviewed By: brecht Maniphest Tasks: T79174 Differential Revision: https://developer.blender.org/D8596 --- intern/cycles/render/stats.h | 64 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) (limited to 'intern/cycles/render/stats.h') diff --git a/intern/cycles/render/stats.h b/intern/cycles/render/stats.h index e45403a3754..5dca6dd0b01 100644 --- a/intern/cycles/render/stats.h +++ b/intern/cycles/render/stats.h @@ -41,6 +41,15 @@ class NamedSizeEntry { size_t size; }; +class NamedTimeEntry { + public: + NamedTimeEntry(); + NamedTimeEntry(const string &name, double time); + + string name; + double time; +}; + /* Container of named size entries. Used, for example, to store per-mesh memory * usage statistics. But also keeps track of overall memory usage of the * container. @@ -64,6 +73,29 @@ class NamedSizeStats { vector entries; }; +class NamedTimeStats { + public: + NamedTimeStats(); + + /* Add entry to the statistics. */ + void add_entry(const NamedTimeEntry &entry) + { + total_time += entry.time; + entries.push_back(entry); + } + + /* Generate full human-readable report. */ + string full_report(int indent_level = 0); + + /* Total time of all entries. */ + double total_time; + + /* NOTE: Is fine to read directly, but for adding use add_entry(), which + * makes sure all accumulating values are properly updated. + */ + vector entries; +}; + class NamedNestedSampleStats { public: NamedNestedSampleStats(); @@ -155,6 +187,38 @@ class RenderStats { NamedSampleCountStats objects; }; +class UpdateTimeStats { + public: + /* Generate full human-readable report. */ + string full_report(int indent_level = 0); + + NamedTimeStats times; +}; + +class SceneUpdateStats { + public: + SceneUpdateStats(); + + UpdateTimeStats geometry; + UpdateTimeStats image; + UpdateTimeStats light; + UpdateTimeStats object; + UpdateTimeStats background; + UpdateTimeStats bake; + UpdateTimeStats camera; + UpdateTimeStats film; + UpdateTimeStats integrator; + UpdateTimeStats osl; + UpdateTimeStats particles; + UpdateTimeStats scene; + UpdateTimeStats svm; + UpdateTimeStats tables; + + string full_report(); + + void clear(); +}; + CCL_NAMESPACE_END #endif /* __RENDER_STATS_H__ */ -- cgit v1.2.3