Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1179)

Side by Side Diff: net/disk_cache/blockfile/histogram_macros.h

Issue 196383016: Put histogram code in disk_cache on a diet. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Restored more code. Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | net/disk_cache/blockfile/histogram_macros_v3.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 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_BLOCKFILE_HISTOGRAM_MACROS_H_ 11 #ifndef NET_DISK_CACHE_BLOCKFILE_HISTOGRAM_MACROS_H_
12 #define NET_DISK_CACHE_BLOCKFILE_HISTOGRAM_MACROS_H_ 12 #define NET_DISK_CACHE_BLOCKFILE_HISTOGRAM_MACROS_H_
13 13
14 // ----------------------------------------------------------------------------- 14 // -----------------------------------------------------------------------------
15 15
16 // These histograms follow the definition of UMA_HISTOGRAMN_XXX except that 16 // These histograms follow the definition of UMA_HISTOGRAMN_XXX except that
17 // whenever the name changes (the experiment group changes), the histrogram 17 // the counter is not cached locally.
18 // object is re-created.
19 // Note: These macros are only run on one thread, so the declarations of
20 // |counter| was made static (i.e., there will be no race for reinitialization).
21 18
22 #define CACHE_HISTOGRAM_CUSTOM_COUNTS(name, sample, min, max, bucket_count) \ 19 #define CACHE_HISTOGRAM_CUSTOM_COUNTS(name, sample, min, max, bucket_count) \
23 do { \ 20 do { \
24 static base::HistogramBase* counter(NULL); \ 21 base::HistogramBase* counter = base::Histogram::FactoryGet( \
25 if (!counter || name != counter->histogram_name()) \
26 counter = base::Histogram::FactoryGet( \
27 name, min, max, bucket_count, \ 22 name, min, max, bucket_count, \
28 base::Histogram::kUmaTargetedHistogramFlag); \ 23 base::Histogram::kUmaTargetedHistogramFlag); \
29 counter->Add(sample); \ 24 counter->Add(sample); \
30 } while (0) 25 } while (0)
31 26
32 #define CACHE_HISTOGRAM_COUNTS(name, sample) CACHE_HISTOGRAM_CUSTOM_COUNTS( \ 27 #define CACHE_HISTOGRAM_COUNTS(name, sample) CACHE_HISTOGRAM_CUSTOM_COUNTS( \
33 name, sample, 1, 1000000, 50) 28 name, sample, 1, 1000000, 50)
34 29
35 #define CACHE_HISTOGRAM_COUNTS_10000(name, sample) \ 30 #define CACHE_HISTOGRAM_COUNTS_10000(name, sample) \
36 CACHE_HISTOGRAM_CUSTOM_COUNTS(name, sample, 1, 10000, 50) 31 CACHE_HISTOGRAM_CUSTOM_COUNTS(name, sample, 1, 10000, 50)
37 32
38 #define CACHE_HISTOGRAM_COUNTS_50000(name, sample) \ 33 #define CACHE_HISTOGRAM_COUNTS_50000(name, sample) \
39 CACHE_HISTOGRAM_CUSTOM_COUNTS(name, sample, 1, 50000000, 50) 34 CACHE_HISTOGRAM_CUSTOM_COUNTS(name, sample, 1, 50000000, 50)
40 35
41 #define CACHE_HISTOGRAM_CUSTOM_TIMES(name, sample, min, max, bucket_count) \ 36 #define CACHE_HISTOGRAM_CUSTOM_TIMES(name, sample, min, max, bucket_count) \
42 do { \ 37 do { \
43 static base::HistogramBase* counter(NULL); \ 38 base::HistogramBase* counter = base::Histogram::FactoryTimeGet( \
44 if (!counter || name != counter->histogram_name()) \
45 counter = base::Histogram::FactoryTimeGet( \
46 name, min, max, bucket_count, \ 39 name, min, max, bucket_count, \
47 base::Histogram::kUmaTargetedHistogramFlag); \ 40 base::Histogram::kUmaTargetedHistogramFlag); \
48 counter->AddTime(sample); \ 41 counter->AddTime(sample); \
49 } while (0) 42 } while (0)
50 43
51 #define CACHE_HISTOGRAM_TIMES(name, sample) CACHE_HISTOGRAM_CUSTOM_TIMES( \ 44 #define CACHE_HISTOGRAM_TIMES(name, sample) CACHE_HISTOGRAM_CUSTOM_TIMES( \
52 name, sample, base::TimeDelta::FromMilliseconds(1), \ 45 name, sample, base::TimeDelta::FromMilliseconds(1), \
53 base::TimeDelta::FromSeconds(10), 50) 46 base::TimeDelta::FromSeconds(10), 50)
54 47
55 #define CACHE_HISTOGRAM_ENUMERATION(name, sample, boundary_value) do { \ 48 #define CACHE_HISTOGRAM_ENUMERATION(name, sample, boundary_value) do { \
56 static base::HistogramBase* counter(NULL); \ 49 base::HistogramBase* counter = base::LinearHistogram::FactoryGet( \
57 if (!counter || name != counter->histogram_name()) \
58 counter = base::LinearHistogram::FactoryGet( \
59 name, 1, boundary_value, boundary_value + 1, \ 50 name, 1, boundary_value, boundary_value + 1, \
60 base::Histogram::kUmaTargetedHistogramFlag); \ 51 base::Histogram::kUmaTargetedHistogramFlag); \
61 counter->Add(sample); \ 52 counter->Add(sample); \
62 } while (0) 53 } while (0)
63 54
64 #define CACHE_HISTOGRAM_PERCENTAGE(name, under_one_hundred) \ 55 #define CACHE_HISTOGRAM_PERCENTAGE(name, under_one_hundred) \
65 CACHE_HISTOGRAM_ENUMERATION(name, under_one_hundred, 101) 56 CACHE_HISTOGRAM_ENUMERATION(name, under_one_hundred, 101)
66 57
67 // ----------------------------------------------------------------------------- 58 // -----------------------------------------------------------------------------
68 59
(...skipping 22 matching lines...) Expand all
91 // CACHE_UMA(COUNTS, "MyName", 0, 20); 82 // CACHE_UMA(COUNTS, "MyName", 0, 20);
92 // CACHE_UMA(COUNTS, "MyExperiment", 530, 55); 83 // CACHE_UMA(COUNTS, "MyExperiment", 530, 55);
93 // which roughly translates to: 84 // which roughly translates to:
94 // UMA_HISTOGRAM_COUNTS("DiskCache.2.MyName", 20); // "2" is the CacheType. 85 // UMA_HISTOGRAM_COUNTS("DiskCache.2.MyName", 20); // "2" is the CacheType.
95 // UMA_HISTOGRAM_COUNTS("DiskCache.2.MyExperiment_530", 55); 86 // UMA_HISTOGRAM_COUNTS("DiskCache.2.MyExperiment_530", 55);
96 // 87 //
97 #define CACHE_UMA(type, name, experiment, sample) {\ 88 #define CACHE_UMA(type, name, experiment, sample) {\
98 const std::string my_name =\ 89 const std::string my_name =\
99 CACHE_UMA_BACKEND_IMPL_OBJ->HistogramName(name, experiment);\ 90 CACHE_UMA_BACKEND_IMPL_OBJ->HistogramName(name, experiment);\
100 switch (CACHE_UMA_BACKEND_IMPL_OBJ->cache_type()) {\ 91 switch (CACHE_UMA_BACKEND_IMPL_OBJ->cache_type()) {\
92 default:\
93 NOTREACHED();\
94 /* Fall-through. */\
101 case net::DISK_CACHE:\ 95 case net::DISK_CACHE:\
102 CACHE_HISTOGRAM_##type(my_name.data(), sample);\
103 break;\
104 case net::MEDIA_CACHE:\ 96 case net::MEDIA_CACHE:\
105 CACHE_HISTOGRAM_##type(my_name.data(), sample);\
106 break;\
107 case net::APP_CACHE:\ 97 case net::APP_CACHE:\
108 CACHE_HISTOGRAM_##type(my_name.data(), sample);\
109 break;\
110 case net::SHADER_CACHE:\ 98 case net::SHADER_CACHE:\
111 CACHE_HISTOGRAM_##type(my_name.data(), sample);\
112 break;\
113 case net::PNACL_CACHE:\ 99 case net::PNACL_CACHE:\
114 CACHE_HISTOGRAM_##type(my_name.data(), sample);\ 100 CACHE_HISTOGRAM_##type(my_name.data(), sample);\
115 break;\ 101 break;\
116 default:\
117 NOTREACHED();\
118 break;\
119 }\ 102 }\
120 } 103 }
121 104
122 #endif // NET_DISK_CACHE_BLOCKFILE_HISTOGRAM_MACROS_H_ 105 #endif // NET_DISK_CACHE_BLOCKFILE_HISTOGRAM_MACROS_H_
OLDNEW
« no previous file with comments | « no previous file | net/disk_cache/blockfile/histogram_macros_v3.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698