OLD | NEW |
1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium OS 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 METRICS_LIBRARY_H_ | 5 #ifndef METRICS_LIBRARY_H_ |
6 #define METRICS_LIBRARY_H_ | 6 #define METRICS_LIBRARY_H_ |
7 | 7 |
8 #include <sys/types.h> | 8 #include <sys/types.h> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 20 matching lines...) Expand all Loading... |
31 // true on success. This method results in the equivalent of an | 31 // true on success. This method results in the equivalent of an |
32 // asynchronous non-blocking RPC to UMA_HISTOGRAM_CUSTOM_COUNTS | 32 // asynchronous non-blocking RPC to UMA_HISTOGRAM_CUSTOM_COUNTS |
33 // inside Chrome (see base/histogram.h). | 33 // inside Chrome (see base/histogram.h). |
34 // | 34 // |
35 // |sample| is the sample value to be recorded (|min| <= |sample| < |max|). | 35 // |sample| is the sample value to be recorded (|min| <= |sample| < |max|). |
36 // |min| is the minimum value of the histogram samples (|min| > 0). | 36 // |min| is the minimum value of the histogram samples (|min| > 0). |
37 // |max| is the maximum value of the histogram samples. | 37 // |max| is the maximum value of the histogram samples. |
38 // |nbuckets| is the number of histogram buckets. | 38 // |nbuckets| is the number of histogram buckets. |
39 // [0,min) is the implicit underflow bucket. | 39 // [0,min) is the implicit underflow bucket. |
40 // [|max|,infinity) is the implicit overflow bucket. | 40 // [|max|,infinity) is the implicit overflow bucket. |
| 41 // |
| 42 // Note that the memory allocated in Chrome for each histogram is |
| 43 // proportional to the number of buckets. Therefore, it is strongly |
| 44 // recommended to keep this number low (e.g., 50 is normal, while |
| 45 // 100 is high). |
41 bool SendToUMA(const std::string& name, int sample, | 46 bool SendToUMA(const std::string& name, int sample, |
42 int min, int max, int nbuckets); | 47 int min, int max, int nbuckets); |
43 | 48 |
44 // Sends linear histogram data to Chrome for transport to UMA and | 49 // Sends linear histogram data to Chrome for transport to UMA and |
45 // returns true on success. This method results in the equivalent of | 50 // returns true on success. This method results in the equivalent of |
46 // an asynchronous non-blocking RPC to UMA_HISTOGRAM_ENUMERATION | 51 // an asynchronous non-blocking RPC to UMA_HISTOGRAM_ENUMERATION |
47 // inside Chrome (see base/histogram.h). | 52 // inside Chrome (see base/histogram.h). |
48 // | 53 // |
49 // |sample| is the sample value to be recorded (1 <= |sample| < |max|). | 54 // |sample| is the sample value to be recorded (1 <= |sample| < |max|). |
50 // |max| is the maximum value of the histogram samples. | 55 // |max| is the maximum value of the histogram samples. |
51 // 0 is the implicit underflow bucket. | 56 // 0 is the implicit underflow bucket. |
52 // [|max|,infinity) is the implicit overflow bucket. | 57 // [|max|,infinity) is the implicit overflow bucket. |
| 58 // |
| 59 // An enumaration histogram requires |max| + 1 number of |
| 60 // buckets. Note that the memory allocated in Chrome for each |
| 61 // histogram is proportional to the number of buckets. Therefore, it |
| 62 // is strongly recommended to keep this number low (e.g., 50 is |
| 63 // normal, while 100 is high). |
53 bool SendEnumToUMA(const std::string& name, int sample, int max); | 64 bool SendEnumToUMA(const std::string& name, int sample, int max); |
54 | 65 |
55 // Sends to Autotest and returns true on success. | 66 // Sends to Autotest and returns true on success. |
56 static bool SendToAutotest(const std::string& name, int value); | 67 static bool SendToAutotest(const std::string& name, int value); |
57 | 68 |
58 private: | 69 private: |
59 friend class CMetricsLibraryTest; | 70 friend class CMetricsLibraryTest; |
60 friend class MetricsLibraryTest; | 71 friend class MetricsLibraryTest; |
61 FRIEND_TEST(MetricsLibraryTest, FormatChromeMessage); | 72 FRIEND_TEST(MetricsLibraryTest, FormatChromeMessage); |
62 FRIEND_TEST(MetricsLibraryTest, FormatChromeMessageTooLong); | 73 FRIEND_TEST(MetricsLibraryTest, FormatChromeMessageTooLong); |
(...skipping 12 matching lines...) Expand all Loading... |
75 // The arbitrary |format| argument covers the non-LENGTH portion of the | 86 // The arbitrary |format| argument covers the non-LENGTH portion of the |
76 // message. The caller is responsible to store the \0 character | 87 // message. The caller is responsible to store the \0 character |
77 // between NAME and VALUE (e.g. "%s%c%d", name, '\0', value). | 88 // between NAME and VALUE (e.g. "%s%c%d", name, '\0', value). |
78 int32_t FormatChromeMessage(int32_t buffer_size, char* buffer, | 89 int32_t FormatChromeMessage(int32_t buffer_size, char* buffer, |
79 const char* format, ...); | 90 const char* format, ...); |
80 | 91 |
81 const char* uma_events_file_; | 92 const char* uma_events_file_; |
82 }; | 93 }; |
83 | 94 |
84 #endif // METRICS_LIBRARY_H_ | 95 #endif // METRICS_LIBRARY_H_ |
OLD | NEW |