Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/blenlib/intern/timeit.cc')
-rw-r--r--source/blender/blenlib/intern/timeit.cc18
1 files changed, 18 insertions, 0 deletions
diff --git a/source/blender/blenlib/intern/timeit.cc b/source/blender/blenlib/intern/timeit.cc
index 2dcfe2e6ab1..f11f9c4ad94 100644
--- a/source/blender/blenlib/intern/timeit.cc
+++ b/source/blender/blenlib/intern/timeit.cc
@@ -2,6 +2,8 @@
#include "BLI_timeit.hh"
+#include <algorithm>
+
namespace blender::timeit {
void print_duration(Nanoseconds duration)
@@ -17,4 +19,20 @@ void print_duration(Nanoseconds duration)
}
}
+ScopedTimerAveraged::~ScopedTimerAveraged()
+{
+ const TimePoint end = Clock::now();
+ const Nanoseconds duration = end - start_;
+
+ total_count_++;
+ total_time_ += duration;
+ min_time_ = std::min(duration, min_time_);
+
+ std::cout << "Timer '" << name_ << "': (Average: ";
+ print_duration(total_time_ / total_count_);
+ std::cout << ", Min: ";
+ print_duration(min_time_);
+ std::cout << ")\n";
+}
+
} // namespace blender::timeit