Consuming Performance Counter Data using the HPX API

HPX provides an API allowing to discover performance counters and to retrieve the current value of any existing performance counter from any application.

Discover Existing Performance Counters
Retrieve the Current Value of any Performance Counter

Performance counters are specialized HPX components. In order to retrieve a counter value, the performance counter needs to be instantiated. HPX exposes a client component object for this purpose:

hpx::performance_counters::performance_counter counter(std::string const& name);

Instantiating an instance of this type will create the performance counter identified by the given name. Only the first invocation for any given counter name will create a new instance of that counter, all following invocations for a given counter name will reference the initially created instance. This ensures, that at any point in time there is always not more than one active instance of any of the existing performance counters

In order to access the counter value (or invoking any of the other functionality related to a performance counter, like start, stop, or reset) member functions of the created client component instance should be called:

// print the current number of threads created on locality 0
hpx::performance_counters::performance_counter count(
hpx::cout << count.get_value<int>() << hpx::endl;

For more information about the client component type see hpx::performance_counters::performance_counter.