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>
24#include <unordered_set>
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,
100 return _allElapsedTimeSnapshot;
106 return _allConsumedTimeSnapshot;
165 MLCallGraphFunctionPtr getOrCreateGlobalFunction(
const std::string& function,
const std::string& filename,
int linenumber,
int userId);
186 bool updateElapsedTime,
192 static void resetGlobalData();
211 static bool _reduceCallGraph;
222 static std::ofstream* _traceStream;
228 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 metaprofile. Do not 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()
Returns whether the call graph should be reduced.
static void resetGlobalFunctionListCopy()
static MLCallGraphNode * callGraphCopy()
Returns the timer copy tree root.
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 void initialize()
Static initialization, is called by the profiling manager.
static void refreshCallGraphCopy()
Resets the timer copy tree root.
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.
const MLCallGraphFunctionSet & usedFunctions() const
Returns the function map.
MLProfilingTimeType allConsumedTimeSnapshot() const
Returns snapshot of the sum of the consumed time of all functions in seconds.
MLTimeProfile(const MLMetaProfile *metaProfile=nullptr)
static void setReduceCallGraph(bool reduceCallGraph)
Sets whether the call graph should be reduced.
MLProfilingTimeType allElapsedTimeSnapshot() const
Returns snapshot of the sum of the elapsed time of all functions in seconds.
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.
static const MLCallGraphFunctionList & globalFunctionListCopy()
Returns copy of the global function list.
MLProfilingTimeType allElapsedTime() const
Returns the sum of the elapsed time of all functions in seconds.
double MLProfilingTimeType
#define MLPROFILINGMANAGER_EXPORT
std::unordered_set< MLCallGraphFunctionPtr > MLCallGraphFunctionSet
std::vector< MLCallGraphFunctionPtr > MLCallGraphFunctionList
boost::unordered_map< MLGlobalFunctionKey, MLCallGraphFunctionPtr > MLCallGraphGlobalFunctionMap
std::vector< MLCallGraphNode * > MLCallGraphNodesVector
std::shared_ptr< MLCallGraphFunction > MLCallGraphFunctionPtr
Time is stored in seconds.