From 2753b39e0c2e83d3b497ebadc2d720f12b74db40 Mon Sep 17 00:00:00 2001 From: "jar@chromium.org" Date: Mon, 28 Dec 2009 06:59:52 +0000 Subject: 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 --- .../websocket_experiment_runner.cc | 61 ++++++++-------------- 1 file changed, 21 insertions(+), 40 deletions(-) (limited to 'chrome/browser/net/websocket_experiment/websocket_experiment_runner.cc') diff --git a/chrome/browser/net/websocket_experiment/websocket_experiment_runner.cc b/chrome/browser/net/websocket_experiment/websocket_experiment_runner.cc index 8d03b6f..845d448 100644 --- a/chrome/browser/net/websocket_experiment/websocket_experiment_runner.cc +++ b/chrome/browser/net/websocket_experiment/websocket_experiment_runner.cc @@ -28,36 +28,27 @@ static const int kWebSocketTimeSec = 10; static const int kTimeBucketCount = 50; // TODO(ukai): Use new thread-safe-reference-counted Histograms. -#define UPDATE_HISTOGRAM(name, sample, min, max, bucket_count) do { \ +#define UPDATE_HISTOGRAM_ENUMS(name, sample, boundary_value) do { \ switch (task_state_) { \ case STATE_RUN_WS: \ { \ - static scoped_refptr counter = \ - LinearHistogram::LinearHistogramFactoryGet(\ - "WebSocketExperiment.Basic." name, \ - min, max, bucket_count); \ - counter->SetFlags(kUmaTargetedHistogramFlag); \ - counter->Add(sample); \ + UMA_HISTOGRAM_ENUMERATION( \ + "WebSocketExperiment.Basic." name, \ + sample, boundary_value); \ } \ break; \ case STATE_RUN_WSS: \ { \ - static scoped_refptr counter = \ - LinearHistogram::LinearHistogramFactoryGet(\ - "WebSocketExperiment.Secure." name, \ - min, max, bucket_count); \ - counter->SetFlags(kUmaTargetedHistogramFlag); \ - counter->Add(sample); \ + UMA_HISTOGRAM_ENUMERATION( \ + "WebSocketExperiment.Secure." name, \ + sample, boundary_value); \ } \ break; \ case STATE_RUN_WS_NODEFAULT_PORT: \ { \ - static scoped_refptr counter = \ - LinearHistogram::LinearHistogramFactoryGet(\ - "WebSocketExperiment.NoDefaultPort." name, \ - min, max, bucket_count); \ - counter->SetFlags(kUmaTargetedHistogramFlag); \ - counter->Add(sample); \ + UMA_HISTOGRAM_ENUMERATION( \ + "WebSocketExperiment.NoDefaultPort." name, \ + sample, boundary_value); \ } \ break; \ default: \ @@ -70,32 +61,23 @@ static const int kTimeBucketCount = 50; switch (task_state_) { \ case STATE_RUN_WS: \ { \ - static scoped_refptr counter = \ - Histogram::HistogramFactoryGet(\ - "WebSocketExperiment.Basic." name, \ - min, max, bucket_count); \ - counter->SetFlags(kUmaTargetedHistogramFlag); \ - counter->AddTime(sample); \ + UMA_HISTOGRAM_CUSTOM_TIMES( \ + "WebSocketExperiment.Basic." name, \ + sample, min, max, bucket_count); \ } \ break; \ case STATE_RUN_WSS: \ { \ - static scoped_refptr counter = \ - Histogram::HistogramFactoryGet(\ - "WebSocketExperiment.Secure." name, \ - min, max, bucket_count); \ - counter->SetFlags(kUmaTargetedHistogramFlag); \ - counter->AddTime(sample); \ + UMA_HISTOGRAM_CUSTOM_TIMES( \ + "WebSocketExperiment.Secure." name, \ + sample, min, max, bucket_count); \ } \ break; \ case STATE_RUN_WS_NODEFAULT_PORT: \ { \ - static scoped_refptr counter = \ - Histogram::HistogramFactoryGet(\ - "WebSocketExperiment.NoDefaultPort." name, \ - min, max, bucket_count); \ - counter->SetFlags(kUmaTargetedHistogramFlag); \ - counter->AddTime(sample); \ + UMA_HISTOGRAM_CUSTOM_TIMES( \ + "WebSocketExperiment.NoDefaultPort." name, \ + sample, min, max, bucket_count); \ } \ break; \ default: \ @@ -277,9 +259,8 @@ void WebSocketExperimentRunner::UpdateTaskResultHistogram( DCHECK(task); const WebSocketExperimentTask::Result& task_result = task->result(); - UPDATE_HISTOGRAM("LastState", task_result.last_state, - 1, WebSocketExperimentTask::NUM_STATES, - WebSocketExperimentTask::NUM_STATES + 1); + UPDATE_HISTOGRAM_ENUMS("LastState", task_result.last_state, + WebSocketExperimentTask::NUM_STATES); UPDATE_HISTOGRAM_TIMES("UrlFetch", task_result.url_fetch, base::TimeDelta::FromMilliseconds(1), -- cgit v1.1