mirror of
https://github.com/NGSolve/netgen.git
synced 2024-12-24 21:10:33 +05:00
Timer - convenience constructors to disable tracing and/or timing
Examples: Timer t0("name"); Timer t1("name", NoTracing); Timer t2("name", NoTiming); Timer t3("name", NoTracing, NoTiming); Timer t4("name", NoTiming, NoTracing);
This commit is contained in:
parent
c5639a5706
commit
6f7543c7dc
@ -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<bool DO_TRACING=true, bool DO_TIMING=true>
|
template<bool DO_TRACING=true, bool DO_TIMING=true>
|
||||||
class Timer
|
class Timer
|
||||||
{
|
{
|
||||||
int timernr;
|
int timernr;
|
||||||
public:
|
int Init( const std::string & name )
|
||||||
Timer (const std::string & name)
|
|
||||||
{
|
{
|
||||||
timernr = NgProfiler::CreateTimer (name);
|
return NgProfiler::CreateTimer (name);
|
||||||
}
|
}
|
||||||
|
public:
|
||||||
|
Timer (const std::string & name) : timernr(Init(name))
|
||||||
|
{ }
|
||||||
|
|
||||||
|
template<typename= std::enable_if<!DO_TRACING>>
|
||||||
|
Timer( const std::string & name, detail::NoTracing_t ) : timernr(Init(name))
|
||||||
|
{ }
|
||||||
|
|
||||||
|
template<typename= std::enable_if<!DO_TIMING>>
|
||||||
|
Timer( const std::string & name, detail::NoTiming_t ) : timernr(Init(name))
|
||||||
|
{ }
|
||||||
|
|
||||||
|
template<typename= std::enable_if<!DO_TRACING&&!DO_TIMING>>
|
||||||
|
Timer( const std::string & name, detail::NoTracing_t, detail::NoTiming_t ) : timernr(Init(name))
|
||||||
|
{ }
|
||||||
|
|
||||||
|
template<typename= std::enable_if<!DO_TRACING&&!DO_TIMING>>
|
||||||
|
Timer( const std::string & name, detail::NoTiming_t, detail::NoTracing_t ) : timernr(Init(name))
|
||||||
|
{ }
|
||||||
|
|
||||||
void SetName (const std::string & name)
|
void SetName (const std::string & name)
|
||||||
{
|
{
|
||||||
NgProfiler::SetName (timernr, name);
|
NgProfiler::SetName (timernr, name);
|
||||||
|
Loading…
Reference in New Issue
Block a user