OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 // This file contains macros to simplify histogram reporting from the disk |
| 6 // cache. The main issue is that we want to have separate histograms for each |
| 7 // type of cache (regular vs. media, etc), without adding the complexity of |
| 8 // keeping track of a potentially large number of histogram objects that have to |
| 9 // survive the backend object that created them. |
| 10 |
| 11 #ifndef NET_DISK_CACHE_HISTOGRAM_MACROS_H_ |
| 12 #define NET_DISK_CACHE_HISTOGRAM_MACROS_H_ |
| 13 |
| 14 // HISTOGRAM_HOURS will collect time related data with a granularity of hours |
| 15 // and normal values of a few months. |
| 16 #define UMA_HISTOGRAM_HOURS UMA_HISTOGRAM_COUNTS_10000 |
| 17 |
| 18 // HISTOGRAM_AGE will collect time elapsed since |initial_time|, with a |
| 19 // granularity of hours and normal values of a few months. |
| 20 #define UMA_HISTOGRAM_AGE(name, initial_time)\ |
| 21 UMA_HISTOGRAM_COUNTS_10000(name, (Time::Now() - initial_time).InHours()) |
| 22 |
| 23 // HISTOGRAM_AGE_MS will collect time elapsed since |initial_time|, with the |
| 24 // normal resolution of the UMA_HISTOGRAM_TIMES. |
| 25 #define UMA_HISTOGRAM_AGE_MS(name, initial_time)\ |
| 26 UMA_HISTOGRAM_TIMES(name, Time::Now() - initial_time) |
| 27 |
| 28 #define UMA_HISTOGRAM_CACHE_ERROR(name, sample) do { \ |
| 29 static LinearHistogram counter((name), 0, 49, 50); \ |
| 30 counter.SetFlags(kUmaTargetedHistogramFlag); \ |
| 31 counter.Add(sample); \ |
| 32 } while (0) |
| 33 |
| 34 #ifdef NET_DISK_CACHE_BACKEND_IMPL_CC_ |
| 35 #define BACKEND_OBJ this |
| 36 #else |
| 37 #define BACKEND_OBJ backend_ |
| 38 #endif |
| 39 |
| 40 // Generates a UMA histogram of the given type, generating the proper name for |
| 41 // it (asking backend_->HistogramName), and adding the provided sample. |
| 42 // For example, to generate a regualar UMA_HISTOGRAM_COUNTS, this macro would |
| 43 // be used as: |
| 44 // CACHE_UMA(COUNTS, "MyName", 0, 20); |
| 45 // CACHE_UMA(COUNTS, "MyExperiment", 530, 55); |
| 46 // which roughly translates to: |
| 47 // UMA_HISTOGRAM_COUNTS("DiskCache.2.MyName", 20); // "2" is the CacheType. |
| 48 // UMA_HISTOGRAM_COUNTS("DiskCache.2.MyExperiment_530", 55); |
| 49 // |
| 50 #define CACHE_UMA(type, name, experiment, sample) {\ |
| 51 const std::string my_name = BACKEND_OBJ->HistogramName(name, experiment);\ |
| 52 switch (BACKEND_OBJ->cache_type()) {\ |
| 53 case net::DISK_CACHE:\ |
| 54 UMA_HISTOGRAM_##type(my_name.data(), sample);\ |
| 55 break;\ |
| 56 case net::MEDIA_CACHE:\ |
| 57 UMA_HISTOGRAM_##type(my_name.data(), sample);\ |
| 58 break;\ |
| 59 case net::TEMP_MEDIA_CACHE:\ |
| 60 UMA_HISTOGRAM_##type(my_name.data(), sample);\ |
| 61 break;\ |
| 62 default:\ |
| 63 NOTREACHED();\ |
| 64 break;\ |
| 65 }\ |
| 66 } |
| 67 |
| 68 #endif // NET_DISK_CACHE_HISTOGRAM_MACROS_H_ |
OLD | NEW |