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/util/util_time.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'intern/cycles/util') diff --git a/intern/cycles/util/util_time.h b/intern/cycles/util/util_time.h index bc9a7414312..a82d400a0d7 100644 --- a/intern/cycles/util/util_time.h +++ b/intern/cycles/util/util_time.h @@ -17,6 +17,7 @@ #ifndef __UTIL_TIME_H__ #define __UTIL_TIME_H__ +#include "util/util_function.h" #include "util/util_string.h" CCL_NAMESPACE_BEGIN @@ -60,6 +61,26 @@ class scoped_timer { double time_start_; }; +class scoped_callback_timer { + public: + using callback_type = function; + + explicit scoped_callback_timer(callback_type cb) : cb(cb) + { + } + + ~scoped_callback_timer() + { + if (cb) { + cb(timer.get_time()); + } + } + + protected: + scoped_timer timer; + callback_type cb; +}; + /* Make human readable string from time, compatible with Blender metadata. */ string time_human_readable_from_seconds(const double seconds); -- cgit v1.2.3