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 BASE_METRICS_HISTOGRAM_SAMPLES_H_ | 5 #ifndef BASE_METRICS_HISTOGRAM_SAMPLES_H_ |
6 #define BASE_METRICS_HISTOGRAM_SAMPLES_H_ | 6 #define BASE_METRICS_HISTOGRAM_SAMPLES_H_ |
7 | 7 |
8 #include "base/atomicops.h" | 8 #include "base/atomicops.h" |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/metrics/histogram_base.h" | 10 #include "base/metrics/histogram_base.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 // by the caller. It is generally used to identify the sample-set across | 24 // by the caller. It is generally used to identify the sample-set across |
25 // threads and processes, though not necessarily uniquely as it is possible | 25 // threads and processes, though not necessarily uniquely as it is possible |
26 // to have multiple sample-sets representing subsets of the data. | 26 // to have multiple sample-sets representing subsets of the data. |
27 const uint64 id; | 27 const uint64 id; |
28 | 28 |
29 // The sum of all the entries, effectivly the sum(sample * count) for | 29 // The sum of all the entries, effectivly the sum(sample * count) for |
30 // all samples. Despite being atomic, no guarantees are made on the | 30 // all samples. Despite being atomic, no guarantees are made on the |
31 // accuracy of this value; there may be races during histogram | 31 // accuracy of this value; there may be races during histogram |
32 // accumulation and snapshotting that we choose to accept. It should | 32 // accumulation and snapshotting that we choose to accept. It should |
33 // be treated as approximate. | 33 // be treated as approximate. |
34 #ifdef ARCH_CPU_64_BITS | 34 // TODO(bcwhite): Change this to std::atomic<uint64>. |
35 subtle::Atomic64 sum; | |
36 #else // No Atomic64 on 32-bit platforms. | |
37 int64 sum; | 35 int64 sum; |
38 #endif | |
39 | 36 |
40 // A "redundant" count helps identify memory corruption. It redundantly | 37 // A "redundant" count helps identify memory corruption. It redundantly |
41 // stores the total number of samples accumulated in the histogram. We | 38 // stores the total number of samples accumulated in the histogram. We |
42 // can compare this count to the sum of the counts (TotalCount() function), | 39 // can compare this count to the sum of the counts (TotalCount() function), |
43 // and detect problems. Note, depending on the implementation of different | 40 // and detect problems. Note, depending on the implementation of different |
44 // histogram types, there might be races during histogram accumulation | 41 // histogram types, there might be races during histogram accumulation |
45 // and snapshotting that we choose to accept. In this case, the tallies | 42 // and snapshotting that we choose to accept. In this case, the tallies |
46 // might mismatch even when no memory corruption has happened. | 43 // might mismatch even when no memory corruption has happened. |
47 HistogramBase::AtomicCount redundant_count; | 44 HistogramBase::AtomicCount redundant_count; |
48 | 45 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 | 106 |
110 // Get the index of current histogram bucket. | 107 // Get the index of current histogram bucket. |
111 // For histograms that don't use predefined buckets, it returns false. | 108 // For histograms that don't use predefined buckets, it returns false. |
112 // Requires: !Done(); | 109 // Requires: !Done(); |
113 virtual bool GetBucketIndex(size_t* index) const; | 110 virtual bool GetBucketIndex(size_t* index) const; |
114 }; | 111 }; |
115 | 112 |
116 } // namespace base | 113 } // namespace base |
117 | 114 |
118 #endif // BASE_METRICS_HISTOGRAM_SAMPLES_H_ | 115 #endif // BASE_METRICS_HISTOGRAM_SAMPLES_H_ |
OLD | NEW |