| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // This file contains macros to simplify histogram reporting from the disk | 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 | 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 | 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 | 8 // keeping track of a potentially large number of histogram objects that have to |
| 9 // survive the backend object that created them. | 9 // survive the backend object that created them. |
| 10 | 10 |
| 11 #ifndef NET_DISK_CACHE_HISTOGRAM_MACROS_H_ | 11 #ifndef NET_DISK_CACHE_HISTOGRAM_MACROS_H_ |
| 12 #define NET_DISK_CACHE_HISTOGRAM_MACROS_H_ | 12 #define NET_DISK_CACHE_HISTOGRAM_MACROS_H_ |
| 13 #pragma once | 13 #pragma once |
| 14 | 14 |
| 15 // ----------------------------------------------------------------------------- | 15 // ----------------------------------------------------------------------------- |
| 16 | 16 |
| 17 // These histograms follow the definition of UMA_HISTOGRAMN_XXX except that | 17 // These histograms follow the definition of UMA_HISTOGRAMN_XXX except that |
| 18 // whenever the name changes (the experiment group changes), the histrogram | 18 // whenever the name changes (the experiment group changes), the histrogram |
| 19 // object is re-created. | 19 // object is re-created. |
| 20 | 20 |
| 21 #define CACHE_HISTOGRAM_CUSTOM_COUNTS(name, sample, min, max, bucket_count) \ | 21 #define CACHE_HISTOGRAM_CUSTOM_COUNTS(name, sample, min, max, bucket_count) \ |
| 22 do { \ | 22 do { \ |
| 23 static scoped_refptr<base::Histogram> counter; \ | 23 scoped_refptr<base::Histogram> counter; \ |
| 24 if (!counter || name != counter->histogram_name()) \ | 24 if (!counter || name != counter->histogram_name()) \ |
| 25 counter = base::Histogram::FactoryGet( \ | 25 counter = base::Histogram::FactoryGet( \ |
| 26 name, min, max, bucket_count, \ | 26 name, min, max, bucket_count, \ |
| 27 base::Histogram::kUmaTargetedHistogramFlag); \ | 27 base::Histogram::kUmaTargetedHistogramFlag); \ |
| 28 counter->Add(sample); \ | 28 counter->Add(sample); \ |
| 29 } while (0) | 29 } while (0) |
| 30 | 30 |
| 31 #define CACHE_HISTOGRAM_COUNTS(name, sample) CACHE_HISTOGRAM_CUSTOM_COUNTS( \ | 31 #define CACHE_HISTOGRAM_COUNTS(name, sample) CACHE_HISTOGRAM_CUSTOM_COUNTS( \ |
| 32 name, sample, 1, 1000000, 50) | 32 name, sample, 1, 1000000, 50) |
| 33 | 33 |
| 34 #define CACHE_HISTOGRAM_COUNTS_10000(name, sample) \ | 34 #define CACHE_HISTOGRAM_COUNTS_10000(name, sample) \ |
| 35 CACHE_HISTOGRAM_CUSTOM_COUNTS(name, sample, 1, 10000, 50) | 35 CACHE_HISTOGRAM_CUSTOM_COUNTS(name, sample, 1, 10000, 50) |
| 36 | 36 |
| 37 #define CACHE_HISTOGRAM_COUNTS_50000(name, sample) \ | 37 #define CACHE_HISTOGRAM_COUNTS_50000(name, sample) \ |
| 38 CACHE_HISTOGRAM_CUSTOM_COUNTS(name, sample, 1, 50000000, 50) | 38 CACHE_HISTOGRAM_CUSTOM_COUNTS(name, sample, 1, 50000000, 50) |
| 39 | 39 |
| 40 #define CACHE_HISTOGRAM_CUSTOM_TIMES(name, sample, min, max, bucket_count) \ | 40 #define CACHE_HISTOGRAM_CUSTOM_TIMES(name, sample, min, max, bucket_count) \ |
| 41 do { \ | 41 do { \ |
| 42 static scoped_refptr<base::Histogram> counter; \ | 42 scoped_refptr<base::Histogram> counter; \ |
| 43 if (!counter || name != counter->histogram_name()) \ | 43 if (!counter || name != counter->histogram_name()) \ |
| 44 counter = base::Histogram::FactoryTimeGet( \ | 44 counter = base::Histogram::FactoryTimeGet( \ |
| 45 name, min, max, bucket_count, \ | 45 name, min, max, bucket_count, \ |
| 46 base::Histogram::kUmaTargetedHistogramFlag); \ | 46 base::Histogram::kUmaTargetedHistogramFlag); \ |
| 47 counter->AddTime(sample); \ | 47 counter->AddTime(sample); \ |
| 48 } while (0) | 48 } while (0) |
| 49 | 49 |
| 50 #define CACHE_HISTOGRAM_TIMES(name, sample) CACHE_HISTOGRAM_CUSTOM_TIMES( \ | 50 #define CACHE_HISTOGRAM_TIMES(name, sample) CACHE_HISTOGRAM_CUSTOM_TIMES( \ |
| 51 name, sample, base::TimeDelta::FromMilliseconds(1), \ | 51 name, sample, base::TimeDelta::FromMilliseconds(1), \ |
| 52 base::TimeDelta::FromSeconds(10), 50) | 52 base::TimeDelta::FromSeconds(10), 50) |
| 53 | 53 |
| 54 #define CACHE_HISTOGRAM_ENUMERATION(name, sample, boundary_value) do { \ | 54 #define CACHE_HISTOGRAM_ENUMERATION(name, sample, boundary_value) do { \ |
| 55 static scoped_refptr<base::Histogram> counter; \ | 55 scoped_refptr<base::Histogram> counter; \ |
| 56 if (!counter || name != counter->histogram_name()) \ | 56 if (!counter || name != counter->histogram_name()) \ |
| 57 counter = base::LinearHistogram::FactoryGet( \ | 57 counter = base::LinearHistogram::FactoryGet( \ |
| 58 name, 1, boundary_value, boundary_value + 1, \ | 58 name, 1, boundary_value, boundary_value + 1, \ |
| 59 base::Histogram::kUmaTargetedHistogramFlag); \ | 59 base::Histogram::kUmaTargetedHistogramFlag); \ |
| 60 counter->Add(sample); \ | 60 counter->Add(sample); \ |
| 61 } while (0) | 61 } while (0) |
| 62 | 62 |
| 63 #define CACHE_HISTOGRAM_PERCENTAGE(name, under_one_hundred) \ | 63 #define CACHE_HISTOGRAM_PERCENTAGE(name, under_one_hundred) \ |
| 64 CACHE_HISTOGRAM_ENUMERATION(name, under_one_hundred, 101) | 64 CACHE_HISTOGRAM_ENUMERATION(name, under_one_hundred, 101) |
| 65 | 65 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 case net::APP_CACHE:\ | 111 case net::APP_CACHE:\ |
| 112 CACHE_HISTOGRAM_##type(my_name.data(), sample);\ | 112 CACHE_HISTOGRAM_##type(my_name.data(), sample);\ |
| 113 break;\ | 113 break;\ |
| 114 default:\ | 114 default:\ |
| 115 NOTREACHED();\ | 115 NOTREACHED();\ |
| 116 break;\ | 116 break;\ |
| 117 }\ | 117 }\ |
| 118 } | 118 } |
| 119 | 119 |
| 120 #endif // NET_DISK_CACHE_HISTOGRAM_MACROS_H_ | 120 #endif // NET_DISK_CACHE_HISTOGRAM_MACROS_H_ |
| OLD | NEW |