diff options
author | rvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-27 20:12:34 +0000 |
---|---|---|
committer | rvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-27 20:12:34 +0000 |
commit | 17a8396f14051151059e95ce14b8a3e27b7c5882 (patch) | |
tree | 01f45ab023a8115f552f81a21da3b5f6cbfd4aa0 /net/disk_cache/histogram_macros.h | |
parent | 63088d3724219e46dfa72818249553bbb6781345 (diff) | |
download | chromium_src-17a8396f14051151059e95ce14b8a3e27b7c5882.zip chromium_src-17a8396f14051151059e95ce14b8a3e27b7c5882.tar.gz chromium_src-17a8396f14051151059e95ce14b8a3e27b7c5882.tar.bz2 |
Disk Cache: Second pass (and final) to allow multiple instances
of BackendImpl.
This cl takes care of all the histograms on the disk cache. Most
of them have to be splitted in three so that we get separate data
from different cache types. There are a few places where the complexity
of splitting the histogram is not worth it so we just keep either all
data together (if it makes sense), or just ignore data for some types of
caches.
note: Having multiple versions of a histogram but only one "active" for a
given client is not the same as having multiple histograms working at the
same time for different objects.
Review URL: http://codereview.chromium.org/42682
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@12692 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/disk_cache/histogram_macros.h')
-rw-r--r-- | net/disk_cache/histogram_macros.h | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/net/disk_cache/histogram_macros.h b/net/disk_cache/histogram_macros.h new file mode 100644 index 0000000..ef88ccf --- /dev/null +++ b/net/disk_cache/histogram_macros.h @@ -0,0 +1,68 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// This file contains macros to simplify histogram reporting from the disk +// cache. The main issue is that we want to have separate histograms for each +// type of cache (regular vs. media, etc), without adding the complexity of +// keeping track of a potentially large number of histogram objects that have to +// survive the backend object that created them. + +#ifndef NET_DISK_CACHE_HISTOGRAM_MACROS_H_ +#define NET_DISK_CACHE_HISTOGRAM_MACROS_H_ + +// HISTOGRAM_HOURS will collect time related data with a granularity of hours +// and normal values of a few months. +#define UMA_HISTOGRAM_HOURS UMA_HISTOGRAM_COUNTS_10000 + +// HISTOGRAM_AGE will collect time elapsed since |initial_time|, with a +// granularity of hours and normal values of a few months. +#define UMA_HISTOGRAM_AGE(name, initial_time)\ + UMA_HISTOGRAM_COUNTS_10000(name, (Time::Now() - initial_time).InHours()) + +// HISTOGRAM_AGE_MS will collect time elapsed since |initial_time|, with the +// normal resolution of the UMA_HISTOGRAM_TIMES. +#define UMA_HISTOGRAM_AGE_MS(name, initial_time)\ + UMA_HISTOGRAM_TIMES(name, Time::Now() - initial_time) + +#define UMA_HISTOGRAM_CACHE_ERROR(name, sample) do { \ + static LinearHistogram counter((name), 0, 49, 50); \ + counter.SetFlags(kUmaTargetedHistogramFlag); \ + counter.Add(sample); \ + } while (0) + +#ifdef NET_DISK_CACHE_BACKEND_IMPL_CC_ +#define BACKEND_OBJ this +#else +#define BACKEND_OBJ backend_ +#endif + +// Generates a UMA histogram of the given type, generating the proper name for +// it (asking backend_->HistogramName), and adding the provided sample. +// For example, to generate a regualar UMA_HISTOGRAM_COUNTS, this macro would +// be used as: +// CACHE_UMA(COUNTS, "MyName", 0, 20); +// CACHE_UMA(COUNTS, "MyExperiment", 530, 55); +// which roughly translates to: +// UMA_HISTOGRAM_COUNTS("DiskCache.2.MyName", 20); // "2" is the CacheType. +// UMA_HISTOGRAM_COUNTS("DiskCache.2.MyExperiment_530", 55); +// +#define CACHE_UMA(type, name, experiment, sample) {\ + const std::string my_name = BACKEND_OBJ->HistogramName(name, experiment);\ + switch (BACKEND_OBJ->cache_type()) {\ + case net::DISK_CACHE:\ + UMA_HISTOGRAM_##type(my_name.data(), sample);\ + break;\ + case net::MEDIA_CACHE:\ + UMA_HISTOGRAM_##type(my_name.data(), sample);\ + break;\ + case net::TEMP_MEDIA_CACHE:\ + UMA_HISTOGRAM_##type(my_name.data(), sample);\ + break;\ + default:\ + NOTREACHED();\ + break;\ + }\ + } + +#endif // NET_DISK_CACHE_HISTOGRAM_MACROS_H_ |