HPX - High Performance ParalleX

Implementing a Full Performance Counter

Somtimes, the simple way of exposing a single value as a Performance Counter is not sufficient. For that reason, HPX provides a means of implementing full Performance Counters which support:

Every full Performance Counter will implement a predefined interface:


In order to implement a full Performance Counter you have to create an HPX component exposing this interface. To simplify this task, HPX provides a ready made base class which handles all the boiler plate of creating a component for you. The remainder of this section will explain the process of creating a full Performance Counter based on the Sine example which you can find in the directory examples/performance_counters/sine/.

The base class is defined in the header file hpx/performance_counters/base_performance_counter.hpp as:


The single template parameter is expected to receive the type of the derived class implementing the Performance Counter. In the Sine example this looks like:

class sine_counter
  : public hpx::performance_counters::base_performance_counter<sine_counter>

i.e. the type sine_counter is derived from the base class passing the type as a template argument (please see sine.hpp for the full source code of the counter definition). For more information about this technique (called Curiously Recurring Template Pattern - CRTP), please see for instance the corresponding Wikipedia article. This base class itself is derived from the performance_counter interface described above.

Additionally, full Performance Counter implementation not only exposes the actual value but also provides information about