diff --git a/libsrc/core/profiler.hpp b/libsrc/core/profiler.hpp index e6795f69..b8bd09e8 100644 --- a/libsrc/core/profiler.hpp +++ b/libsrc/core/profiler.hpp @@ -148,16 +148,42 @@ namespace ngcore }; + namespace detail { + struct NoTracing_t{}; + struct NoTiming_t{}; + } + + static detail::NoTracing_t NoTracing; + static detail::NoTiming_t NoTiming; template class Timer { int timernr; - public: - Timer (const std::string & name) + int Init( const std::string & name ) { - timernr = NgProfiler::CreateTimer (name); + return NgProfiler::CreateTimer (name); } + public: + Timer (const std::string & name) : timernr(Init(name)) + { } + + template> + Timer( const std::string & name, detail::NoTracing_t ) : timernr(Init(name)) + { } + + template> + Timer( const std::string & name, detail::NoTiming_t ) : timernr(Init(name)) + { } + + template> + Timer( const std::string & name, detail::NoTracing_t, detail::NoTiming_t ) : timernr(Init(name)) + { } + + template> + Timer( const std::string & name, detail::NoTiming_t, detail::NoTracing_t ) : timernr(Init(name)) + { } + void SetName (const std::string & name) { NgProfiler::SetName (timernr, name);