OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef SYNC_UTIL_DATA_TYPE_HISTOGRAM_H_ | 5 #ifndef SYNC_UTIL_DATA_TYPE_HISTOGRAM_H_ |
6 #define SYNC_UTIL_DATA_TYPE_HISTOGRAM_H_ | 6 #define SYNC_UTIL_DATA_TYPE_HISTOGRAM_H_ |
7 | 7 |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/metrics/sparse_histogram.h" | |
9 #include "base/time/time.h" | 10 #include "base/time/time.h" |
10 #include "sync/internal_api/public/base/model_type.h" | 11 #include "sync/internal_api/public/base/model_type.h" |
11 | 12 |
13 // This macro adds |value| to |sample| bucket of histogram |name|. |value| | |
14 // should be greater or equal to 1 and |name| can be variable. DataTypes are | |
15 // mapped to proper |sample| bucket by using ModelTypeToHistogramInt() function. | |
16 // So different DataTypes play the role of different buckets in this histogram. | |
17 #define SYNC_RECORD_DATATYPE_BIN(name, sample, value) \ | |
sclittle
2015/08/19 22:41:35
Does this have to be a macro? Would this be better
amohammadkhan
2015/08/20 00:20:13
Done.
Nicolas Zea
2015/08/20 17:59:50
Actually, if I recall how histograms work you migh
amohammadkhan
2015/08/20 18:12:51
I see your point. But I used it without static poi
| |
18 do { \ | |
19 base::HistogramBase* histogram = base::SparseHistogram::FactoryGet( \ | |
20 name, base::HistogramBase::kUmaTargetedHistogramFlag); \ | |
21 histogram->AddCount(sample, value); \ | |
22 } while (0) | |
23 | |
12 // For now, this just implements UMA_HISTOGRAM_LONG_TIMES. This can be adjusted | 24 // For now, this just implements UMA_HISTOGRAM_LONG_TIMES. This can be adjusted |
13 // if we feel the min, max, or bucket count amount are not appropriate. | 25 // if we feel the min, max, or bucket count amount are not appropriate. |
14 #define SYNC_FREQ_HISTOGRAM(name, time) UMA_HISTOGRAM_CUSTOM_TIMES( \ | 26 #define SYNC_FREQ_HISTOGRAM(name, time) UMA_HISTOGRAM_CUSTOM_TIMES( \ |
15 name, time, base::TimeDelta::FromMilliseconds(1), \ | 27 name, time, base::TimeDelta::FromMilliseconds(1), \ |
16 base::TimeDelta::FromHours(1), 50) | 28 base::TimeDelta::FromHours(1), 50) |
17 | 29 |
18 // Helper macro for datatype specific histograms. For each datatype, invokes | 30 // Helper macro for datatype specific histograms. For each datatype, invokes |
19 // a pre-defined PER_DATA_TYPE_MACRO(type_str), where |type_str| is the string | 31 // a pre-defined PER_DATA_TYPE_MACRO(type_str), where |type_str| is the string |
20 // version of the datatype. | 32 // version of the datatype. |
21 // | 33 // |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
138 case ::syncer::PROXY_TABS: \ | 150 case ::syncer::PROXY_TABS: \ |
139 PER_DATA_TYPE_MACRO("Tabs"); \ | 151 PER_DATA_TYPE_MACRO("Tabs"); \ |
140 break; \ | 152 break; \ |
141 default: \ | 153 default: \ |
142 NOTREACHED() << "Unknown datatype " \ | 154 NOTREACHED() << "Unknown datatype " \ |
143 << ::syncer::ModelTypeToString(datatype); \ | 155 << ::syncer::ModelTypeToString(datatype); \ |
144 } \ | 156 } \ |
145 } while (0) | 157 } while (0) |
146 | 158 |
147 #endif // SYNC_UTIL_DATA_TYPE_HISTOGRAM_H_ | 159 #endif // SYNC_UTIL_DATA_TYPE_HISTOGRAM_H_ |
OLD | NEW |