[Bf-blender-cvs] [4e65de7db61] rigid_deform: bring back timer

Jacques Lucke noreply at git.blender.org
Thu Jan 31 19:56:05 CET 2019


Commit: 4e65de7db61f62756018140958679ba1c03605f4
Author: Jacques Lucke
Date:   Tue Jan 29 20:38:48 2019 +0100
Branches: rigid_deform
https://developer.blender.org/rB4e65de7db61f62756018140958679ba1c03605f4

bring back timer

===================================================================

M	source/blender/modifiers/intern/MOD_rigiddeform_system.cc

===================================================================

diff --git a/source/blender/modifiers/intern/MOD_rigiddeform_system.cc b/source/blender/modifiers/intern/MOD_rigiddeform_system.cc
index e3a2825c412..ca3a899c8b9 100644
--- a/source/blender/modifiers/intern/MOD_rigiddeform_system.cc
+++ b/source/blender/modifiers/intern/MOD_rigiddeform_system.cc
@@ -26,6 +26,36 @@
 #include "MOD_rigiddeform_system.hpp"
 #include "BLI_math.h"
 
+#include <chrono>
+
+/* ************** Timer ***************** */
+
+class Timer {
+    const char *name;
+    std::chrono::high_resolution_clock::time_point start, end;
+    std::chrono::duration<float> duration;
+
+public:
+    Timer(const char *name = "");
+    ~Timer();
+};
+
+Timer::Timer(const char *name) {
+    this->name = name;
+    this->start = std::chrono::high_resolution_clock::now();
+}
+
+Timer::~Timer() {
+    end = std::chrono::high_resolution_clock::now();
+    duration = end - start;
+    double ms = duration.count() * 1000.0f;
+    std::cout << "Timer '" << name << "' took " << ms << " ms" << std::endl;
+}
+
+#define TIMEIT(name) Timer t(name);
+
+/* ************ Timer End *************** */
+
 namespace RigidDeform {
 
 	/* expects the anchor indices to be sorted */



More information about the Bf-blender-cvs mailing list