MeVisLab Toolbox Reference
Loading...
Searching...
No Matches
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
20namespace internal
21{
24 {
25
26 public:
28 : _profile(nullptr)
29 {}
31 {
32 if (_profile) {
33 _profile->stopMeasuring(_handle);
34 }
35 }
36
37 void startMeasuring(MLMetaProfile* profile, const std::string& function, int userId, void* userData)
38 {
39 _profile = profile;
40 _handle = profile->startMeasuring(function, userId, userData);
41 }
42
43 private:
44 MLTimeProfileHandle _handle;
45 MLMetaProfile* _profile;
46 };
47} // namespace internal
49
52#define ML_PROFILING_SCOPE(ProfilingIdentifier) \
53 internal::ProfilingScope internal_scope; \
54 if (MLProfilingManager::isProfilingEnabled()) { \
55 MLMetaProfile* internal_metaProfile = NULL; \
56 internal_metaProfile = getMetaProfile().get(); \
57 if (internal_metaProfile) { \
58 internal_scope.startMeasuring(internal_metaProfile, ProfilingIdentifier, MLMetaProfile::MLCall, this); \
59 } \
60 }
61
62#endif
Helper class that stops measuring when it gets out of scope.
void startMeasuring(MLMetaProfile *profile, const std::string &function, int userId, void *userData)
Target mlrange_cast(Source arg)
Generic version of checked ML casts.