SummarizingMetric(const char * name, T initial_value, bool reg_new = true) : impl::MetricBase(name, reg_new) , initial_value(initial_value) , value_(initial_value) , n(0) // TODO: this assumes initial_value is not actually a value , mean(initial_value) , M2(0) , min(std::numeric_limits<T>::max()) , max(std::numeric_limits<T>::min()) { #ifdef VTRACE_SAMPLED if (SummarizingMetric::vt_type == -1) { LOG(ERROR) << "warning: VTrace sampling unsupported for this type of SummarizingMetric."; } else { std::string namestr( name ); std::string countstr = namestr + "_count"; std::string meanstr = namestr + "_mean"; std::string stddevstr = namestr + "_stddev"; vt_counter_value = VT_COUNT_DEF(name, name, SummarizingMetric::vt_type, VT_COUNT_DEFGROUP); vt_counter_count = VT_COUNT_DEF(countstr.c_str(), countstr.c_str(), VT_COUNT_TYPE_UNSIGNED, VT_COUNT_DEFGROUP); vt_counter_mean = VT_COUNT_DEF(meanstr.c_str(), meanstr.c_str(), VT_COUNT_TYPE_DOUBLE, VT_COUNT_DEFGROUP); vt_counter_stddev = VT_COUNT_DEF(stddevstr.c_str(), stddevstr.c_str(), VT_COUNT_TYPE_DOUBLE, VT_COUNT_DEFGROUP); } #endif }
// reset using function // IMPORTANT: currently, this forces the merge to do a min instead of a sum SimpleMetric(const char * name, InitFn initf, bool reg_new = true): value_(initf()), initf_(initf), impl::MetricBase(name, reg_new) { #ifdef VTRACE_SAMPLED if (SimpleMetric::vt_type == -1) { LOG(ERROR) << "warning: VTrace sampling unsupported for this type of SimpleMetric."; } else { vt_counter = VT_COUNT_DEF(name, name, SimpleMetric::vt_type, VT_COUNT_DEFGROUP); } #endif }
MaxMetric(const char * name, T initial_value, bool reg_new = true): initial_value(initial_value), value_(initial_value), impl::MetricBase(name, reg_new) { #ifdef VTRACE_SAMPLED if (MaxMetric::vt_type == -1) { LOG(ERROR) << "warning: VTrace sampling unsupported for this type of MaxMetric."; } else { vt_counter = VT_COUNT_DEF(name, name, MaxMetric::vt_type, VT_COUNT_DEFGROUP); } #endif }