15#ifndef ML_TIME_PROFILE_H
16#define ML_TIME_PROFILE_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,
166 static void resetGlobalData();
181 static bool _reduceCallGraph;
190 static std::ofstream* _traceStream;
196 friend class MLABModuleProfile;
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.
const MLMetaProfile * metaProfile() const
Returns the meta profile. Don't assume that the pointer is valid!
MLCallGraphFunctionPtr getFunctionForTesting(const std::string &function) const
Returns the function pointer or NULL.
void reset()
Resets the time profile.
static bool shouldReduceCallGraph()
Gets if 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 if 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 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...
static const MLCallGraphFunctionList & globalFunctionList()
Returns the global function list.
MLProfilingTimeType allConsumedTime() const
Returns the sum of the consumed time of all functions in seconds.
static void disableTracing()
Disables call tracing.
static const MLCallGraphGlobalFunctionMap & globalFunctionMap()
Returns the global function map.
MLTimeProfile(const MLMetaProfile *metaProfile=nullptr)
static void setReduceCallGraph(bool reduceCallGraph)
Sets if 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)
Enable 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
Target mlrange_cast(Source arg)
Generic version of checked ML casts.
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.