summaryrefslogtreecommitdiffstats
path: root/net/socket_stream
diff options
context:
space:
mode:
authorjar@chromium.org <jar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-28 06:59:52 +0000
committerjar@chromium.org <jar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-28 06:59:52 +0000
commit2753b39e0c2e83d3b497ebadc2d720f12b74db40 (patch)
tree01edf034e65922a229b3ccbaef8291059ac5e2bc /net/socket_stream
parente660e88dc26b9b31c48c815b2358212ea4067ca5 (diff)
downloadchromium_src-2753b39e0c2e83d3b497ebadc2d720f12b74db40.zip
chromium_src-2753b39e0c2e83d3b497ebadc2d720f12b74db40.tar.gz
chromium_src-2753b39e0c2e83d3b497ebadc2d720f12b74db40.tar.bz2
Cleanup histogram classes mixing SetFlags into FactoryGet arguments
Generic cleanup of histogram class, renaming *FactoryGet to FactoryGet, along with reformatting. The macros were cleaned up to use common sub-macros rather than repeating code as much. Removed ThreadSafeHistogram (and associated ASSET_HISTOGRAM macros) since this class was not getting used. I introduced UMA_HISTOGRAM_ENUMERATION to support the common use of LinearHistograms to count various enumerated values. I added a Flags argument to all the FactoryGet routines to help avoid needing to call SetFlags each time a new sample is Add()ed. This also simplifies the code. This will all help prepare for a "don't histogram at all" macro setting so that I can test the impact of the histogram macro calls on performance (since there are now so many active histograms). BUG=31206 r=raman.tenneti Review URL: http://codereview.chromium.org/515033 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@35295 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/socket_stream')
-rw-r--r--net/socket_stream/socket_stream_metrics.cc16
-rw-r--r--net/socket_stream/socket_stream_metrics_unittest.cc18
2 files changed, 13 insertions, 21 deletions
diff --git a/net/socket_stream/socket_stream_metrics.cc b/net/socket_stream/socket_stream_metrics.cc
index 6220eb5..625a491 100644
--- a/net/socket_stream/socket_stream_metrics.cc
+++ b/net/socket_stream/socket_stream_metrics.cc
@@ -83,21 +83,13 @@ void SocketStreamMetrics::OnClose() {
}
void SocketStreamMetrics::CountProtocolType(ProtocolType protocol_type) {
- static scoped_refptr<Histogram> counter =
- LinearHistogram::LinearHistogramFactoryGet(
- "Net.SocketStream.ProtocolType",
- 0, NUM_PROTOCOL_TYPES, NUM_PROTOCOL_TYPES + 1);
- counter->SetFlags(kUmaTargetedHistogramFlag);
- counter->Add(protocol_type);
+ UMA_HISTOGRAM_ENUMERATION("Net.SocketStream.ProtocolType",
+ protocol_type, NUM_PROTOCOL_TYPES);
}
void SocketStreamMetrics::CountConnectionType(ConnectionType connection_type) {
- static scoped_refptr<Histogram> counter =
- LinearHistogram::LinearHistogramFactoryGet(
- "Net.SocketStream.ConnectionType",
- 1, NUM_CONNECTION_TYPES, NUM_CONNECTION_TYPES + 1);
- counter->SetFlags(kUmaTargetedHistogramFlag);
- counter->Add(connection_type);
+ UMA_HISTOGRAM_ENUMERATION("Net.SocketStream.ConnectionType",
+ connection_type, NUM_CONNECTION_TYPES);
}
diff --git a/net/socket_stream/socket_stream_metrics_unittest.cc b/net/socket_stream/socket_stream_metrics_unittest.cc
index e29ee3f..7d44f79 100644
--- a/net/socket_stream/socket_stream_metrics_unittest.cc
+++ b/net/socket_stream/socket_stream_metrics_unittest.cc
@@ -42,7 +42,7 @@ TEST(SocketStreamMetricsTest, ProtocolType) {
ASSERT_TRUE(StatisticsRecorder::FindHistogram(
"Net.SocketStream.ProtocolType", &histogram));
- EXPECT_EQ(kUmaTargetedHistogramFlag, histogram->flags());
+ EXPECT_EQ(Histogram::kUmaTargetedHistogramFlag, histogram->flags());
Histogram::SampleSet sample;
histogram->SnapshotSample(&sample);
@@ -75,7 +75,7 @@ TEST(SocketStreamMetricsTest, ConnectionType) {
ASSERT_TRUE(StatisticsRecorder::FindHistogram(
"Net.SocketStream.ConnectionType", &histogram));
- EXPECT_EQ(kUmaTargetedHistogramFlag, histogram->flags());
+ EXPECT_EQ(Histogram::kUmaTargetedHistogramFlag, histogram->flags());
Histogram::SampleSet sample;
histogram->SnapshotSample(&sample);
@@ -134,46 +134,46 @@ TEST(SocketStreamMetricsTest, OtherNumbers) {
// ConnectionLatency.
ASSERT_TRUE(StatisticsRecorder::FindHistogram(
"Net.SocketStream.ConnectionLatency", &histogram));
- EXPECT_EQ(kUmaTargetedHistogramFlag, histogram->flags());
+ EXPECT_EQ(Histogram::kUmaTargetedHistogramFlag, histogram->flags());
// We don't check the contents of the histogram as it's time sensitive.
// ConnectionEstablish.
ASSERT_TRUE(StatisticsRecorder::FindHistogram(
"Net.SocketStream.ConnectionEstablish", &histogram));
- EXPECT_EQ(kUmaTargetedHistogramFlag, histogram->flags());
+ EXPECT_EQ(Histogram::kUmaTargetedHistogramFlag, histogram->flags());
// We don't check the contents of the histogram as it's time sensitive.
// Duration.
ASSERT_TRUE(StatisticsRecorder::FindHistogram(
"Net.SocketStream.Duration", &histogram));
- EXPECT_EQ(kUmaTargetedHistogramFlag, histogram->flags());
+ EXPECT_EQ(Histogram::kUmaTargetedHistogramFlag, histogram->flags());
// We don't check the contents of the histogram as it's time sensitive.
// ReceivedBytes.
ASSERT_TRUE(StatisticsRecorder::FindHistogram(
"Net.SocketStream.ReceivedBytes", &histogram));
- EXPECT_EQ(kUmaTargetedHistogramFlag, histogram->flags());
+ EXPECT_EQ(Histogram::kUmaTargetedHistogramFlag, histogram->flags());
histogram->SnapshotSample(&sample);
EXPECT_EQ(11, sample.sum() - original_received_bytes); // 11 bytes read.
// ReceivedCounts.
ASSERT_TRUE(StatisticsRecorder::FindHistogram(
"Net.SocketStream.ReceivedCounts", &histogram));
- EXPECT_EQ(kUmaTargetedHistogramFlag, histogram->flags());
+ EXPECT_EQ(Histogram::kUmaTargetedHistogramFlag, histogram->flags());
histogram->SnapshotSample(&sample);
EXPECT_EQ(2, sample.sum() - original_received_counts); // 2 read requests.
// SentBytes.
ASSERT_TRUE(StatisticsRecorder::FindHistogram(
"Net.SocketStream.SentBytes", &histogram));
- EXPECT_EQ(kUmaTargetedHistogramFlag, histogram->flags());
+ EXPECT_EQ(Histogram::kUmaTargetedHistogramFlag, histogram->flags());
histogram->SnapshotSample(&sample);
EXPECT_EQ(222, sample.sum() - original_sent_bytes); // 222 bytes sent.
// SentCounts.
ASSERT_TRUE(StatisticsRecorder::FindHistogram(
"Net.SocketStream.SentCounts", &histogram));
- EXPECT_EQ(kUmaTargetedHistogramFlag, histogram->flags());
+ EXPECT_EQ(Histogram::kUmaTargetedHistogramFlag, histogram->flags());
histogram->SnapshotSample(&sample);
EXPECT_EQ(3, sample.sum() - original_sent_counts); // 3 write requests.
}