From 25efdadd057aa0d5261dc93608a61943d425cc48 Mon Sep 17 00:00:00 2001 From: Matthias Hochsteger Date: Tue, 13 Oct 2020 11:11:33 +0200 Subject: [PATCH] helper macro for Timer/RegionTimer definition --- libsrc/core/profiler.hpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/libsrc/core/profiler.hpp b/libsrc/core/profiler.hpp index 36c10d55..c16c242c 100644 --- a/libsrc/core/profiler.hpp +++ b/libsrc/core/profiler.hpp @@ -301,5 +301,14 @@ namespace ngcore } // namespace ngcore +// Helper macro to easily add multiple timers in a function for profiling +// Usage: NETGEN_TIMER_FROM_HERE("my_timer_name") +// Effect: define static Timer and RegionTimer with given name and line number +#define NETGEN_TOKEN_CONCAT(x, y) x ## y +#define NETGEN_TOKEN_CONCAT2(x, y) NETGEN_TOKEN_CONCAT(x, y) +#define NETGEN_TIMER_FROM_HERE(name) \ + static Timer NETGEN_TOKEN_CONCAT2(timer_, __LINE__)( string(name)+"_"+ToString(__LINE__)); \ + RegionTimer NETGEN_TOKEN_CONCAT2(rt_,__LINE__)(NETGEN_TOKEN_CONCAT2(timer_,__LINE__)); + #endif // NETGEN_CORE_PROFILER_HPP