Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(974)

Side by Side Diff: base/metrics/histogram_base.cc

Issue 1141793003: Update from https://crrev.com/329939 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/message_loop/message_pump_perftest.cc ('k') | base/metrics/statistics_recorder.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/metrics/histogram_base.h" 5 #include "base/metrics/histogram_base.h"
6 6
7 #include <climits> 7 #include <climits>
8 8
9 #include "base/json/json_string_value_serializer.h" 9 #include "base/json/json_string_value_serializer.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 GetCountAndBucketData(&count, &sum, buckets.get()); 104 GetCountAndBucketData(&count, &sum, buckets.get());
105 scoped_ptr<DictionaryValue> parameters(new DictionaryValue()); 105 scoped_ptr<DictionaryValue> parameters(new DictionaryValue());
106 GetParameters(parameters.get()); 106 GetParameters(parameters.get());
107 107
108 JSONStringValueSerializer serializer(output); 108 JSONStringValueSerializer serializer(output);
109 DictionaryValue root; 109 DictionaryValue root;
110 root.SetString("name", histogram_name()); 110 root.SetString("name", histogram_name());
111 root.SetInteger("count", count); 111 root.SetInteger("count", count);
112 root.SetDouble("sum", static_cast<double>(sum)); 112 root.SetDouble("sum", static_cast<double>(sum));
113 root.SetInteger("flags", flags()); 113 root.SetInteger("flags", flags());
114 root.Set("params", parameters.release()); 114 root.Set("params", parameters.Pass());
115 root.Set("buckets", buckets.release()); 115 root.Set("buckets", buckets.Pass());
116 root.SetInteger("pid", GetCurrentProcId()); 116 root.SetInteger("pid", GetCurrentProcId());
117 serializer.Serialize(root); 117 serializer.Serialize(root);
118 } 118 }
119 119
120 void HistogramBase::WriteAsciiBucketGraph(double current_size, 120 void HistogramBase::WriteAsciiBucketGraph(double current_size,
121 double max_size, 121 double max_size,
122 std::string* output) const { 122 std::string* output) const {
123 const int k_line_length = 72; // Maximal horizontal width of graph. 123 const int k_line_length = 72; // Maximal horizontal width of graph.
124 int x_count = static_cast<int>(k_line_length * (current_size / max_size) 124 int x_count = static_cast<int>(k_line_length * (current_size / max_size)
125 + 0.5); 125 + 0.5);
(...skipping 16 matching lines...) Expand all
142 return result; 142 return result;
143 } 143 }
144 144
145 void HistogramBase::WriteAsciiBucketValue(Count current, 145 void HistogramBase::WriteAsciiBucketValue(Count current,
146 double scaled_sum, 146 double scaled_sum,
147 std::string* output) const { 147 std::string* output) const {
148 StringAppendF(output, " (%d = %3.1f%%)", current, current/scaled_sum); 148 StringAppendF(output, " (%d = %3.1f%%)", current, current/scaled_sum);
149 } 149 }
150 150
151 } // namespace base 151 } // namespace base
OLDNEW
« no previous file with comments | « base/message_loop/message_pump_perftest.cc ('k') | base/metrics/statistics_recorder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698