24 #include "glog/logging.h" 36 const float min = *std::min_element(
values_.begin(),
values_.end());
37 const float max = *std::max_element(
values_.begin(),
values_.end());
40 string result =
"Count: " + std::to_string(
values_.size()) +
41 " Min: " + std::to_string(min) +
42 " Max: " + std::to_string(max) +
43 " Mean: " + std::to_string(mean);
48 float lower_bound = min;
50 for (
int i = 0; i != buckets; ++i) {
51 const float upper_bound =
54 : (max * (i + 1) / buckets + min * (buckets - i - 1) / buckets);
57 if (lower_bound <=
value &&
58 (i + 1 == buckets ?
value <= upper_bound :
value < upper_bound)) {
63 result +=
"\n[" + std::to_string(lower_bound) +
", " +
64 std::to_string(upper_bound) + ((i + 1 == buckets) ?
"]" :
")");
65 constexpr
int kMaxBarChars = 20;
67 (count * kMaxBarChars + values_.size() / 2) / values_.size();
69 for (
int i = 0; i != kMaxBarChars; ++i) {
70 result += (i < (kMaxBarChars - bar)) ?
" " :
"#";
72 result +=
"\tCount: " + std::to_string(count) +
" (" +
73 std::to_string(count * 1e2f / values_.size()) +
"%)";
74 result +=
"\tTotal: " + std::to_string(total_count) +
" (" +
75 std::to_string(total_count * 1e2f / values_.size()) +
"%)";
76 lower_bound = upper_bound;
std::vector< float > values_
string ToString(int buckets) const