39 #ifndef HPP_FCL_UTIL_PROFILER 40 #define HPP_FCL_UTIL_PROFILER 42 #define ENABLE_PROFILING 1 44 #ifndef ENABLE_PROFILING 49 # define ENABLE_PROFILING 0 51 # define ENABLE_PROFILING 1 61 #include <boost/thread.hpp> 62 #include <boost/noncopyable.hpp> 63 #include <boost/date_time/posix_time/posix_time.hpp> 77 typedef boost::posix_time::ptime
point;
80 typedef boost::posix_time::time_duration
duration;
83 inline point
now(
void)
85 return boost::posix_time::microsec_clock::universal_time();
91 long int s =
static_cast<long int>(sec);
92 long int us = ((
static_cast<long int>(sec) - s) * 1000000);
99 return (
double)d.total_microseconds() / 1000000.0;
167 Profiler(
bool printOnDestroy =
false,
bool autoStart =
false) : running_(false), printOnDestroy_(printOnDestroy)
176 if (printOnDestroy_ && !data_.empty())
208 static void Event(
const std::string& name,
const unsigned int times = 1)
210 Instance().
event(name, times);
214 void event(
const std::string &name,
const unsigned int times = 1);
217 static void Average(
const std::string& name,
const double value)
219 Instance().
average(name, value);
223 void average(
const std::string &name,
const double value);
226 static void Begin(
const std::string &name)
228 Instance().
begin(name);
232 static void End(
const std::string &name)
234 Instance().
end(name);
238 void begin(
const std::string &name);
241 void end(
const std::string &name);
246 static void Status(std::ostream &out = std::cout,
bool merge =
true)
248 Instance().
status(out, merge);
254 void status(std::ostream &out = std::cout,
bool merge =
true);
273 TimeInfo(
void) : total(0, 0, 0, 0), shortest(boost::posix_time::pos_infin), longest(boost::posix_time::neg_infin), parts(0)
287 unsigned long int parts;
321 unsigned long int parts;
328 std::map<std::string, unsigned long int> events;
331 std::map<std::string, AvgInfo> avg;
334 std::map<std::string, TimeInfo> time;
337 void printThreadInfo(std::ostream &out,
const PerThread &data);
340 std::map<boost::thread::id, PerThread> data_;
343 bool printOnDestroy_;
371 ScopedBlock(
const std::string &, Profiler & = Profiler::Instance())
384 ScopedStart(Profiler & = Profiler::Instance())
393 static Profiler& Instance(
void);
395 Profiler(
bool =
true,
bool =
true)
403 static void Start(
void)
407 static void Stop(
void)
411 static void Clear(
void)
427 static void Event(
const std::string&,
const unsigned int = 1)
431 void event(
const std::string &,
const unsigned int = 1)
435 static void Average(
const std::string&,
const double)
439 void average(
const std::string &,
const double)
443 static void Begin(
const std::string &)
447 static void End(
const std::string &)
451 void begin(
const std::string &)
455 void end(
const std::string &)
459 static void Status(std::ostream & = std::cout,
bool =
true)
463 void status(std::ostream & = std::cout,
bool =
true)
467 bool running(
void)
const 472 static bool Running(
void)
boost::posix_time::ptime point
Representation of a point in time.
Definition: profile.h:77
Main namespace.
Definition: AABB.h:43
double seconds(const duration &d)
Return the number of seconds that a time duration represents.
Definition: profile.h:97
duration seconds(double sec)
Return the time duration representing a given number of seconds.
Definition: profile.h:89
point now(void)
Get the current time point.
Definition: profile.h:83
boost::posix_time::time_duration duration
Representation of a time duration.
Definition: profile.h:80
#define HPP_FCL_DLLAPI
Definition: config.hh:64