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

Side by Side Diff: tools/metrics/histograms/README.md

Issue 2866293002: Metrics Documentation - Add Instruction for How To Unit Test (Closed)
Patch Set: Created 3 years, 7 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 | « tools/metrics/actions/README.md ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Histogram Guidelines 1 # Histogram Guidelines
2 2
3 This document gives the best practices on how to use histograms in code and how 3 This document gives the best practices on how to use histograms in code and how
4 to document the histograms for the dashboards. There are three general types 4 to document the histograms for the dashboards. There are three general types
5 of histograms: enumerated histograms, count histograms (for arbitrary numbers), 5 of histograms: enumerated histograms, count histograms (for arbitrary numbers),
6 and sparse histograms (for anything when the precision is important over a wide 6 and sparse histograms (for anything when the precision is important over a wide
7 range and/or the range is not possible to specify a priori). 7 range and/or the range is not possible to specify a priori).
8 8
9 [TOC] 9 [TOC]
10 10
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 pieces of information need to be logged together. For example, a developer may 118 pieces of information need to be logged together. For example, a developer may
119 be interested in the counts of features X and Y based on whether a user is in 119 be interested in the counts of features X and Y based on whether a user is in
120 state A or B. In this case, they want to know the count of X under state A, 120 state A or B. In this case, they want to know the count of X under state A,
121 as well as the other three permutations. 121 as well as the other three permutations.
122 122
123 There is no general purpose solution for this type of analysis. We suggest 123 There is no general purpose solution for this type of analysis. We suggest
124 using the workaround of using an enum of length MxN, where you log each unique 124 using the workaround of using an enum of length MxN, where you log each unique
125 pair {state, feature} as a separate entry in the same enum. If this causes a 125 pair {state, feature} as a separate entry in the same enum. If this causes a
126 large explosion in data (i.e. >100 enum entries), a [sparse histogram](#When-To- Use-Sparse-Histograms) may be appropriate. If you are unsure of the best way to proceed, please contact someone from the OWNERS file. 126 large explosion in data (i.e. >100 enum entries), a [sparse histogram](#When-To- Use-Sparse-Histograms) may be appropriate. If you are unsure of the best way to proceed, please contact someone from the OWNERS file.
127 127
128 ### Testing 128 ## Testing
129 129
130 Test your histograms using `chrome://histograms`. Make sure they're being 130 Test your histograms using `chrome://histograms`. Make sure they're being
131 emitted to when you expect and not emitted to at other times. Also check that 131 emitted to when you expect and not emitted to at other times. Also check that
132 the values emitted to are correct. Finally, for count histograms, make sure 132 the values emitted to are correct. Finally, for count histograms, make sure
133 that buckets capture enough precision for your needs over the range. 133 that buckets capture enough precision for your needs over the range.
134 134
135 ### Revising Histograms 135 In addition to testing interactively, you can have unit tests examine the
136 values emitted to histograms. See [histogram_tester.h](https://cs.chromium.org/ chromium/src/base/test/histogram_tester.h)
137 for details.
136 138
137 If you're changing the semantics of a histogram (when it's emitted, what 139 ## Revising Histograms
138 buckets mean, etc.), make it into a new histogram with a new name. Otherwise 140
139 the "Everything" view on the dashboard will be mixing two different 141 When changing the semantics of a histogram (when it's emitted, what buckets
142 mean, etc.), make it into a new histogram with a new name. Otherwise the
143 "Everything" view on the dashboard will be mixing two different
140 interpretations of the data and make no sense. 144 interpretations of the data and make no sense.
141 145
142 ### Deleting Histograms 146 ## Deleting Histograms
143 147
144 Please delete the code that emits to histograms that are no longer needed. 148 Please delete the code that emits to histograms that are no longer needed.
145 Histograms take up memory. Cleaning up histograms that you no longer care about 149 Histograms take up memory. Cleaning up histograms that you no longer care about
146 is good! But see the note below on [Deleting Histogram Entries](#Deleting-Histo gram-Entries). 150 is good! But see the note below on [Deleting Histogram Entries](#Deleting-Histo gram-Entries).
147 151
148 ## Documenting Histograms 152 ## Documenting Histograms
149 153
150 ### Add Histogram and Documentation in the Same Changelist 154 ### Add Histogram and Documentation in the Same Changelist
151 155
152 If possible, please add the [histograms.xml](./histograms.xml) description in 156 If possible, please add the [histograms.xml](./histograms.xml) description in
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 Sparse histograms are well suited for recording counts of exact sample values 207 Sparse histograms are well suited for recording counts of exact sample values
204 that are sparsely distributed over a large range. 208 that are sparsely distributed over a large range.
205 209
206 The implementation uses a lock and a map, whereas other histogram types use a 210 The implementation uses a lock and a map, whereas other histogram types use a
207 vector and no lock. It is thus more costly to add values to, and each value 211 vector and no lock. It is thus more costly to add values to, and each value
208 stored has more overhead, compared to the other histogram types. However it 212 stored has more overhead, compared to the other histogram types. However it
209 may be more efficient in memory if the total number of sample values is small 213 may be more efficient in memory if the total number of sample values is small
210 compared to the range of their values. 214 compared to the range of their values.
211 215
212 For more information, see [sparse_histograms.h](https://cs.chromium.org/chromium /src/base/metrics/sparse_histogram.h). 216 For more information, see [sparse_histograms.h](https://cs.chromium.org/chromium /src/base/metrics/sparse_histogram.h).
OLDNEW
« no previous file with comments | « tools/metrics/actions/README.md ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698