diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2020-01-24 17:14:28 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2020-01-24 17:19:29 +0300 |
commit | 6b28b7773057da6dc72067e4ff4f1d646e87aaca (patch) | |
tree | 886dad33bca2f97a70026176d2301378e4a84d34 /source/blender/depsgraph/intern/debug/deg_debug.cc | |
parent | 21892d5592551082590a58a01a4a0961e9cf2acc (diff) |
Depsgraph: Report FPS when running with --debug-depsgraph-time
The FPS here is measured based on a timestamp from when depsgraph
was previously evaluated.
Allows to ease investigating performance improvements/regressions
which are not related on animation system but on modifications on
a single frame (such as transforming vertex in edit mode).
Diffstat (limited to 'source/blender/depsgraph/intern/debug/deg_debug.cc')
-rw-r--r-- | source/blender/depsgraph/intern/debug/deg_debug.cc | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/source/blender/depsgraph/intern/debug/deg_debug.cc b/source/blender/depsgraph/intern/debug/deg_debug.cc index b8db18c9958..00ff73b8f63 100644 --- a/source/blender/depsgraph/intern/debug/deg_debug.cc +++ b/source/blender/depsgraph/intern/debug/deg_debug.cc @@ -28,12 +28,48 @@ #include "BLI_hash.h" #include "BLI_string.h" +#include "PIL_time_utildefines.h" + #include "BKE_global.h" namespace DEG { -DepsgraphDebug::DepsgraphDebug() : flags(G.debug) +DepsgraphDebug::DepsgraphDebug() + : flags(G.debug), is_ever_evaluated(false), graph_evaluation_start_time_(0) +{ +} + +bool DepsgraphDebug::do_time_debug() const +{ + return ((G.debug & G_DEBUG_DEPSGRAPH_TIME) != 0); +} + +void DepsgraphDebug::begin_graph_evaluation() +{ + if (!do_time_debug()) { + return; + } + + const double current_time = PIL_check_seconds_timer(); + + if (is_ever_evaluated) { + fps_samples_.add_sample(current_time - graph_evaluation_start_time_); + } + + graph_evaluation_start_time_ = current_time; +} + +void DepsgraphDebug::end_graph_evaluation() { + if (!do_time_debug()) { + return; + } + + const double graph_eval_end_time = PIL_check_seconds_timer(); + printf("Depsgraph updated in %f seconds.\n", graph_eval_end_time - graph_evaluation_start_time_); + printf("Depsgraph evaluation FPS: %f\n", fps_samples_.get_averaged()); + + is_ever_evaluated = true; } bool terminal_do_color(void) |