Skip to content

Commit

Permalink
Merge pull request #3206 from victor-ludorum/count_arithmetic_perform…
Browse files Browse the repository at this point in the history
…ance_counter

Addition of new arithmetic performance counter "Count"
  • Loading branch information
hkaiser committed Mar 4, 2018
2 parents d4be8df + 8cee918 commit 3e55a8f
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 0 deletions.
9 changes: 9 additions & 0 deletions docs/manual/existing_performance_counters.qbk
Expand Up @@ -1659,6 +1659,15 @@ system and application performance.
this counter is accessed. Any wildcards in the counter names will
be expanded.]
]
[ [`/arithmetics/count`]
[None]
[Returns the count value of all values queried from the
underlying counters (the ones specified as the parameters).]
[The parameter will be interpreted as a comma separated list of
full performance counter names which are queried whenever
this counter is accessed. Any wildcards in the counter names will
be expanded.]
]
]

[note The /arithmetics counters can consume an arbitrary number of other counters.
Expand Down
8 changes: 8 additions & 0 deletions src/performance_counters/registry.cpp
Expand Up @@ -987,6 +987,14 @@ namespace hpx { namespace performance_counters
gid = components::server::construct<counter_t>(
complemented_info, base_counter_names);
}
else if (p.countername_ == "count") {
typedef hpx::components::component<
performance_counters::server::arithmetics_counter_extended<
boost::accumulators::tag::count>
> counter_t;
gid = components::server::construct<counter_t>(
complemented_info, base_counter_names);
}
else {
HPX_THROWS_IF(ec, bad_parameter,
"registry::create_arithmetics_counter",
Expand Down
26 changes: 26 additions & 0 deletions src/performance_counters/server/arithmetics_counter_extended.cpp
Expand Up @@ -22,6 +22,7 @@
#include <boost/accumulators/statistics/variance.hpp>
#include <boost/accumulators/statistics/max.hpp>
#include <boost/accumulators/statistics/min.hpp>
#include <boost/accumulators/statistics/count.hpp>

#include <cstddef>
#include <cstdint>
Expand Down Expand Up @@ -103,6 +104,16 @@ namespace hpx { namespace performance_counters { namespace server
return (boost::accumulators::max)(accum);
}
};

template <>
struct statistic_get_value<boost::accumulators::tag::count>
{
template <typename Accumulator>
static double call(Accumulator const& accum)
{
return boost::accumulators::count(accum);
}
};
}

template <typename Statistic>
Expand Down Expand Up @@ -175,6 +186,9 @@ hpx::performance_counters::server::arithmetics_counter_extended<
template class HPX_EXPORT
hpx::performance_counters::server::arithmetics_counter_extended<
boost::accumulators::tag::max>;
template class HPX_EXPORT
hpx::performance_counters::server::arithmetics_counter_extended<
boost::accumulators::tag::count>;

///////////////////////////////////////////////////////////////////////////////
// /arithmetic/mean
Expand Down Expand Up @@ -236,6 +250,18 @@ HPX_REGISTER_DERIVED_COMPONENT_FACTORY(
"base_performance_counter", hpx::components::factory_enabled)
HPX_DEFINE_GET_COMPONENT_TYPE(max_arithmetics_counter_type::wrapped_type)

///////////////////////////////////////////////////////////////////////////////
// /arithmetic/count
typedef hpx::components::component<
hpx::performance_counters::server::arithmetics_counter_extended<
boost::accumulators::tag::count>
> count_arithmetics_counter_type;

HPX_REGISTER_DERIVED_COMPONENT_FACTORY(
count_arithmetics_counter_type, count_arithmetics_counter,
"base_performance_counter", hpx::components::factory_enabled)
HPX_DEFINE_GET_COMPONENT_TYPE(count_arithmetics_counter_type::wrapped_type)

///////////////////////////////////////////////////////////////////////////////
namespace hpx { namespace performance_counters { namespace detail
{
Expand Down
10 changes: 10 additions & 0 deletions src/runtime.cpp
Expand Up @@ -649,6 +649,16 @@ namespace hpx
&performance_counters::default_counter_discoverer,
""
},
// arithmetics count counter
{ "/arithmetics/count", performance_counters::counter_aggregating,
"returns the count value of all values of the specified "
"base counters; pass the required base counters as the parameters: "
"/arithmetics/count@<base_counter_name1>,<base_counter_name2>",
HPX_PERFORMANCE_COUNTER_V1,
&performance_counters::detail::arithmetics_counter_extended_creator,
&performance_counters::default_counter_discoverer,
""
},
};
performance_counters::install_counter_types(
arithmetic_counter_types,
Expand Down

0 comments on commit 3e55a8f

Please sign in to comment.