15 #ifndef ML_TIME_PROFILE_H
16 #define ML_TIME_PROFILE_H
20 #include "../Include/mlCallGraph.h"
22 #include <boost/thread/thread.hpp>
23 #include <boost/unordered_map.hpp>
49 friend class ProfilingTest_TestCallGraphIsRecursive_Test;
50 friend class ProfilingTest_TestProfileAccumulation_Test;
66 const std::string& filename,
68 const std::string& nodeInfo =
"");
79 const std::string& filename,
139 MLCallGraphFunctionPtr getOrCreateGlobalFunction(
const std::string&
function,
const std::string& filename,
int linenumber,
int userId);
160 bool updateElapsedTime,
166 static void resetGlobalData();
181 static bool _reduceCallGraph;
190 static std::ofstream* _traceStream;
196 friend class MLABModuleProfile;
static const MLCallGraphFunctionList & globalFunctionList()
Returns the global function list.
static MLCallGraphFunctionPtr getFunctionGlobal(const std::string &function, const std::string &filename, int linenumber)
Returns the function pointer or NULL.
void stopMeasuring(MLTimeProfileHandle &handle, bool ignoreIfEmpty=false)
Stops measuring time and associates the elapsed time.
MLCallGraphFunctionPtr getFunctionForTesting(const std::string &function) const
Returns the function pointer or NULL.
void reset()
Resets the time profile.
static bool shouldReduceCallGraph()
Returns whether the call graph should be reduced.
const MLCallGraphFunctionMap & functionMap() const
Returns the function map.
static void deinitialize()
Static deinitialization, is called by the profiling manager.
static bool isTracingEnabled()
Returns whether call tracing is enabled.
static MLCallGraphNode & callGraph()
Returns the timer tree root.
MLTimeProfileHandle startMeasuring(const std::string &function, int userId, void *userData, const std::string &filename, int linenumber, const std::string &nodeInfo="")
Starts measuring time.
static const MLCallGraphGlobalFunctionMap & globalFunctionMap()
Returns the global function map.
static void initialize()
Static initialization, is called by the profiling manager.
void addTimeToFunction(const std::string &function, int userId, const std::string &filename, int linenumber, MLProfilingTimeType time, int callCount)
Adds time to the given function, without measuring and without putting the function onto the call sta...
MLProfilingTimeType allConsumedTime() const
Returns the sum of the consumed time of all functions in seconds.
static void disableTracing()
Disables call tracing.
MLTimeProfile(const MLMetaProfile *metaProfile=nullptr)
const MLMetaProfile * metaProfile() const
Returns the metaprofile. Do not assume that the pointer is valid!
static void setReduceCallGraph(bool reduceCallGraph)
Sets whether the call graph should be reduced.
static MLProfilingTimeType globalElapsedTime()
Returns the global elapsed time in seconds.
static MLCallGraphFunctionPtr mainFunction
static void enableTracing(const char *filename)
Enables call tracing and set the trace filname.
MLProfilingTimeType allElapsedTime() const
Returns the sum of the elapsed time of all functions in seconds.
double MLProfilingTimeType
std::shared_ptr< MLCallGraphFunction > MLCallGraphFunctionPtr
#define MLPROFILINGMANAGER_EXPORT
boost::unordered_map< MLCallGraphFunction *, MLCallGraphFunctionPtr > MLCallGraphFunctionMap
std::vector< MLCallGraphFunctionPtr > MLCallGraphFunctionList
boost::unordered_map< MLGlobalFunctionKey, MLCallGraphFunctionPtr > MLCallGraphGlobalFunctionMap
std::vector< MLCallGraphNode * > MLCallGraphNodesVector
std::shared_ptr< MLCallGraphFunction > MLCallGraphFunctionPtr
Time is stored in seconds.