[Bf-blender-cvs] [7863cf89de5] functions: cleanup ScopedTimer
Jacques Lucke
noreply at git.blender.org
Wed May 22 17:32:24 CEST 2019
Commit: 7863cf89de5d19f8da3b88a4cd9911cd01c4e072
Author: Jacques Lucke
Date: Wed May 22 15:41:20 2019 +0200
Branches: functions
https://developer.blender.org/rB7863cf89de5d19f8da3b88a4cd9911cd01c4e072
cleanup ScopedTimer
===================================================================
M source/blender/blenlib/BLI_timeit.hpp
M source/blender/functions/frontends/data_flow_nodes/data_flow_nodes-c.cpp
===================================================================
diff --git a/source/blender/blenlib/BLI_timeit.hpp b/source/blender/blenlib/BLI_timeit.hpp
index 9b9e9b374b9..7dca46d59e2 100644
--- a/source/blender/blenlib/BLI_timeit.hpp
+++ b/source/blender/blenlib/BLI_timeit.hpp
@@ -9,28 +9,30 @@
namespace BLI {
-class Timer {
+class ScopedTimer {
private:
- const char *name;
- std::chrono::high_resolution_clock::time_point start, end;
- std::chrono::duration<float> duration;
+ using Clock = std::chrono::high_resolution_clock;
+ using Duration = std::chrono::duration<float>;
+
+ const char *m_name;
+ Clock::time_point m_start;
public:
- Timer(const char *name = "")
+ ScopedTimer(const char *name = "")
{
- this->name = name;
- this->start = std::chrono::high_resolution_clock::now();
+ m_name = name;
+ m_start = Clock::now();
}
- ~Timer()
+ ~ScopedTimer()
{
- end = std::chrono::high_resolution_clock::now();
- duration = end - start;
+ Clock::time_point end = Clock::now();
+ Duration duration = end - m_start;
double ms = duration.count() * 1000.0f;
- std::cout << "Timer '" << name << "' took " << ms << " ms" << std::endl;
+ std::cout << "Timer '" << m_name << "' took " << ms << " ms\n";
}
};
}; // namespace BLI
-#define TIMEIT(name) BLI::Timer t(name);
+#define SCOPED_TIMER(name) BLI::ScopedTimer t(name);
diff --git a/source/blender/functions/frontends/data_flow_nodes/data_flow_nodes-c.cpp b/source/blender/functions/frontends/data_flow_nodes/data_flow_nodes-c.cpp
index 49cc1b25ea9..77ad365960d 100644
--- a/source/blender/functions/frontends/data_flow_nodes/data_flow_nodes-c.cpp
+++ b/source/blender/functions/frontends/data_flow_nodes/data_flow_nodes-c.cpp
@@ -5,7 +5,7 @@ using namespace FN;
FnFunction FN_tree_to_function(bNodeTree *btree)
{
- TIMEIT("Tree to function");
+ SCOPED_TIMER("Tree to function");
BLI_assert(btree);
auto fn_opt = DataFlowNodes::generate_function(btree);
if (!fn_opt.has_value()) {
More information about the Bf-blender-cvs
mailing list