Source release v3.5.0

This commit is contained in:
Gene Morgan
2017-11-28 17:42:16 -08:00
parent 501c22890d
commit 31381a1311
155 changed files with 16680 additions and 3816 deletions

View File

@@ -0,0 +1,63 @@
// Copyright 2017 Google Inc. All Rights Reserved.
//
// This file contains implementations for the BaseEventMetric.
#include "event_metric.h"
namespace wvcdm {
namespace metrics {
BaseEventMetric::~BaseEventMetric() {
AutoLock lock(internal_lock_);
for (std::map<std::string, Distribution*>::iterator it
= value_map_.begin(); it != value_map_.end(); it++) {
delete it->second;
}
}
void BaseEventMetric::Record(const std::string& field_names_values,
double value) {
AutoLock lock(internal_lock_);
Distribution* distribution;
if (value_map_.find(field_names_values) == value_map_.end()) {
distribution = new Distribution();
value_map_[field_names_values] = distribution;
} else {
distribution = value_map_[field_names_values];
}
distribution->Record(value);
}
void BaseEventMetric::Serialize(MetricSerializer* serializer) {
AutoLock lock(internal_lock_);
for (std::map<std::string, Distribution*>::iterator it
= value_map_.begin(); it != value_map_.end(); it++) {
serializer->SetInt64(
metric_name_ + "/count" + it->first,
it->second->Count());
serializer->SetDouble(
metric_name_ + "/mean" + it->first,
it->second->Mean());
// Only publish additional information if there was more than one sample.
if (it->second->Count() > 1) {
serializer->SetDouble(
metric_name_ + "/variance" + it->first,
it->second->Variance());
serializer->SetDouble(
metric_name_ + "/min" + it->first,
it->second->Min());
serializer->SetDouble(
metric_name_ + "/max" + it->first,
it->second->Max());
}
}
}
} // namespace metrics
} // namespace wvcdm