Event count(const events_t & events) { if (events.empty()) { return {}; } return events.front().copy().set_metric(events.size()) .set_time(max_time(events)); }
Event mean(const events_t & events) { if (events.empty()) { return {}; } Event e(events.front()); e.set_metric_d(reduce(sum_fn, events) / events.size()); e.set_time(max_time(events)); return e; }
Event maximum(const events_t & events) { if (events.empty()) { return {}; } double max = events[0].metric(); for (const auto & e: events) { auto tmp = e.metric(); if (tmp > max) { max = tmp; } } Event e(events.front()); e.set_metric_d(max); e.set_time(max_time(events)); return e; }
Event minimum(const events_t & events) { if (events.empty()) { return {}; } double min = metric_to_double(events[0]); for (const auto & e: events) { auto tmp = metric_to_double(e); if (tmp < min) { min = tmp; } } Event e(events.front()); e.set_metric_d(min); e.set_time(max_time(events)); return e; }