MeVisLab Toolbox Reference
mlModuleProfiling.h
Go to the documentation of this file.
1 /*************************************************************************************
2 **
3 ** Copyright 2014, MeVis Medical Solutions AG
4 **
5 ** The user may use this file in accordance with the license agreement provided with
6 ** the Software or, alternatively, in accordance with the terms contained in a
7 ** written agreement between the user and MeVis Medical Solutions AG.
8 **
9 ** For further information use the contact form at https://www.mevislab.de/contact
10 **
11 **************************************************************************************/
12 
13 #ifndef ML_MODULE_PROFILING_H
14 #define ML_MODULE_PROFILING_H
15 
16 #include <mlTypeDefs.h>
17 #include <mlProfilingManager.h>
18 
19 ML_START_NAMESPACE
20 namespace internal
21 {
24 
25  public:
26  ProfilingScope():_profile(nullptr) {}
28  if (_profile) {
29  _profile->stopMeasuring(_handle);
30  }
31  }
32 
33  void startMeasuring(MLMetaProfile* profile, const std::string& function, int userId, void* userData)
34  {
35  _profile = profile;
36  _handle = profile->startMeasuring(function, userId, userData);
37  }
38 
39  private:
40  MLTimeProfileHandle _handle;
41  MLMetaProfile* _profile;
42  };
43 }
44 ML_END_NAMESPACE
45 
48 #define ML_PROFILING_SCOPE(ProfilingIdentifier) \
49  internal::ProfilingScope internal_scope; \
50  if (MLProfilingManager::isProfilingEnabled()) { \
51  MLMetaProfile* internal_metaProfile = NULL; \
52  internal_metaProfile = getMetaProfile().get(); \
53  if (internal_metaProfile) { \
54  internal_scope.startMeasuring(internal_metaProfile, ProfilingIdentifier, MLMetaProfile::MLCall, this); \
55  } \
56  }
57 
58 #endif
59 
60 
MLTimeProfileHandle startMeasuring(const std::string &function, int userId, void *userData=nullptr, const std::string &filename="", int linenumber=-1, const std::string &nodeInfo="")
Starts measuring time.
Helper class that stops measuring when it gets out of scope.
void startMeasuring(MLMetaProfile *profile, const std::string &function, int userId, void *userData)