Go to the documentation of this file.
52 : running_(false), printOnDestroy_(printOnDestroy)
128 data_[std::this_thread::get_id()].events[
name] += times;
165 data_[std::this_thread::get_id()].time[
name].set();
173 data_[std::this_thread::get_id()].time[
name].update();
191 out <<
" *** Profiling statistics. Total counted time : " <<
time::seconds(
tinfo_.
total) <<
" seconds" << std::endl;
196 for (std::map<std::thread::id, PerThread>::const_iterator it =
data_.begin() ; it !=
data_.end() ; ++it)
198 for (std::map<std::string, unsigned long int>::const_iterator iev = it->second.events.begin() ; iev != it->second.events.end(); ++iev)
199 combined.
events[iev->first] += iev->second;
200 for (std::map<std::string, AvgInfo>::const_iterator iavg = it->second.avg.begin() ; iavg != it->second.avg.end(); ++iavg)
202 combined.
avg[iavg->first].total += iavg->second.total;
203 combined.
avg[iavg->first].totalSqr += iavg->second.totalSqr;
204 combined.
avg[iavg->first].parts += iavg->second.parts;
206 for (std::map<std::string, TimeInfo>::const_iterator itm = it->second.time.begin() ; itm != it->second.time.end(); ++itm)
211 if (tc.
shortest > itm->second.shortest)
213 if (tc.
longest < itm->second.longest)
214 tc.
longest = itm->second.longest;
220 for (std::map<std::thread::id, PerThread>::const_iterator it =
data_.begin() ; it !=
data_.end() ; ++it)
222 out <<
"Thread " << it->first <<
":" << std::endl;
277 std::vector<detail::dataIntVal> events;
278 for (std::map<std::string, unsigned long int>::const_iterator iev = data.
events.begin() ; iev != data.
events.end() ; ++iev)
281 events.push_back(
next);
285 out <<
"Events:" << std::endl;
286 for (
unsigned int i = 0 ; i < events.size() ; ++i)
287 out << events[i].
name <<
": " << events[i].value << std::endl;
289 std::vector<detail::dataDoubleVal> avg;
290 for (std::map<std::string, AvgInfo>::const_iterator ia = data.
avg.begin() ; ia != data.
avg.end() ; ++ia)
297 out <<
"Averages:" << std::endl;
298 for (
unsigned int i = 0 ; i < avg.size() ; ++i)
301 out << avg[i].name <<
": " << avg[i].value <<
" (stddev = " <<
302 std::sqrt(std::abs(a.
totalSqr - (
double)a.
parts * avg[i].value * avg[i].value) / ((
double)a.
parts - 1.)) <<
")" << std::endl;
305 std::vector<detail::dataDoubleVal> time;
307 for (std::map<std::string, TimeInfo>::const_iterator itm = data.
time.begin() ; itm != data.
time.end() ; ++itm)
310 time.push_back(
next);
315 out <<
"Blocks of time:" << std::endl;
317 double unaccounted = total;
318 for (
unsigned int i = 0 ; i < time.size() ; ++i)
324 out << time[i].name <<
": " << time[i].value <<
"s (" << (100.0 * time[i].value/total) <<
"%), ["
325 << tS <<
"s --> " << tL <<
" s], " << d.
parts <<
" parts";
329 unaccounted -= time[i].value;
331 out <<
"Unaccounted time : " << unaccounted;
333 out <<
" (" << (100.0 * unaccounted / total) <<
" %)";
371 Profiler::ScopedStart::ScopedStart(
Profiler& prof)
379 Profiler::ScopedStart::~ScopedStart()
386 Profiler::ScopedBlock::ScopedBlock(
const std::string&
name,
Profiler& prof)
393 Profiler::ScopedBlock::~ScopedBlock()
Profiler(const Profiler &)=delete
static void Status(std::ostream &out=std::cout, bool merge=true)
Print the status of the profiled code chunks and events. Optionally, computation done by different th...
std::chrono::system_clock::duration duration
Representation of a time duration.
time::duration total
Total time counted.
std::map< std::string, AvgInfo > avg
The stored averages.
void begin(const std::string &name)
Begin counting time for a specific chunk of code.
unsigned long int parts
Number of times a value was added to this structure.
void event(const std::string &name, const unsigned int times=1)
Count a specific event for a number of times.
bool running(void) const
Check if the profiler is counting time or not.
void set(void)
Begin counting time.
void printThreadInfo(std::ostream &out, const PerThread &data)
Information maintained about averaged values.
std::map< std::thread::id, PerThread > data_
void stop(void)
Stop counting time.
double totalSqr
The sub of squares of the values to average.
time::duration shortest
The shortest counted time interval.
bool operator()(const dataDoubleVal &a, const dataDoubleVal &b) const
double total
The sum of the values to average.
static void Begin(const std::string &name)
Begin counting time for a specific chunk of code.
void end(const std::string &name)
Stop counting time for a specific chunk of code.
static void Average(const std::string &name, const double value)
Maintain the average of a specific value.
~Profiler(void)
Destructor.
static Profiler & Instance(void)
Return an instance of the class.
static void Clear(void)
Clear counted time and events.
std::map< std::string, TimeInfo > time
The amount of time spent in various places.
EndPoint * next[3]
the next end point in the end point list
void clear(void)
Clear counted time and events.
unsigned long int parts
Number of times a chunk of time was added to this structure.
void update(void)
Add the counted time to the total time.
Information about time spent in a section of the code.
static void Start(void)
Start counting time.
static void Event(const std::string &name, const unsigned int times=1)
Count a specific event for a number of times.
FCL_EXPORT point now(void)
Get the current time point.
std::map< std::string, unsigned long int > events
The stored events.
bool operator()(const dataIntVal &a, const dataIntVal &b) const
void start(void)
Start counting time.
void status(std::ostream &out=std::cout, bool merge=true)
Print the status of the profiled code chunks and events. Optionally, computation done by different th...
Information to be maintained for each thread.
static void End(const std::string &name)
Stop counting time for a specific chunk of code.
static void Stop(void)
Stop counting time.
This is a simple thread-safe tool for counting time spent in various chunks of code....
static bool Running(void)
Check if the profiler is counting time or not.
void average(const std::string &name, const double value)
Maintain the average of a specific value.
time::duration longest
The longest counted time interval.
FCL_EXPORT duration seconds(double sec)
Return the time duration representing a given number of seconds.
fcl
Author(s):
autogenerated on Tue Dec 5 2023 03:40:48