2014-01-03 08:20:13 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <stddef.h>
|
2016-07-31 03:53:16 +00:00
|
|
|
#include <atomic>
|
2014-01-03 08:20:13 +00:00
|
|
|
|
|
|
|
|
2016-10-24 02:02:37 +00:00
|
|
|
/** Implements global counters for various events happening in the application
|
|
|
|
* - for high level profiling.
|
|
|
|
* See .cpp for list of events.
|
2014-01-03 08:20:13 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
namespace ProfileEvents
|
|
|
|
{
|
2016-10-24 02:02:37 +00:00
|
|
|
/// Event identifier (index in array).
|
|
|
|
using Event = size_t;
|
|
|
|
using Count = size_t;
|
2014-01-03 08:20:13 +00:00
|
|
|
|
2016-10-24 04:06:27 +00:00
|
|
|
/// Get text description of event by identifier. Returns statically allocated string.
|
2016-10-24 02:02:37 +00:00
|
|
|
const char * getDescription(Event event);
|
2014-01-03 08:20:13 +00:00
|
|
|
|
2016-10-24 02:02:37 +00:00
|
|
|
/// Counters - how many times each event happened.
|
|
|
|
extern std::atomic<Count> counters[];
|
2014-01-03 08:20:13 +00:00
|
|
|
|
2016-10-24 02:02:37 +00:00
|
|
|
/// Increment a counter for event. Thread-safe.
|
|
|
|
inline void increment(Event event, Count amount = 1)
|
2014-01-03 08:20:13 +00:00
|
|
|
{
|
2016-07-31 03:53:16 +00:00
|
|
|
counters[event] += amount;
|
2014-01-03 08:20:13 +00:00
|
|
|
}
|
|
|
|
|
2016-10-24 02:02:37 +00:00
|
|
|
/// Get index just after last event identifier.
|
|
|
|
Event end();
|
|
|
|
}
|