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

Side by Side Diff: src/platform/metrics/metrics_client.cc

Issue 1747008: Add support for linear/enumeration histograms. (Closed)
Patch Set: Created 10 years, 8 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 | src/platform/metrics/metrics_library.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) 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 #include <cstdio> 5 #include <cstdio>
6 #include <cstdlib> 6 #include <cstdlib>
7 7
8 #include "metrics_library.h" 8 #include "metrics_library.h"
9 9
10 int main(int argc, char** argv) { 10 int main(int argc, char** argv) {
11 bool send_to_autotest = false; 11 bool send_to_autotest = false;
12 bool send_to_chrome = true; 12 bool send_to_chrome = true;
13 bool send_enum = false;
13 bool secs_to_msecs = false; 14 bool secs_to_msecs = false;
14 int name_index = 1; 15 int name_index = 1;
15 bool print_usage = false; 16 bool print_usage = false;
16 17
17 if (argc >= 3) { 18 if (argc >= 3) {
18 // Parse arguments 19 // Parse arguments
19 int flag; 20 int flag;
20 while ((flag = getopt(argc, argv, "abt")) != -1) { 21 while ((flag = getopt(argc, argv, "abet")) != -1) {
21 switch (flag) { 22 switch (flag) {
22 case 'a': 23 case 'a':
23 send_to_autotest = true; 24 send_to_autotest = true;
24 send_to_chrome = false; 25 send_to_chrome = false;
25 break; 26 break;
26 case 'b': 27 case 'b':
27 send_to_chrome = true; 28 send_to_chrome = true;
28 send_to_autotest = true; 29 send_to_autotest = true;
29 break; 30 break;
31 case 'e':
32 send_enum = true;
33 break;
30 case 't': 34 case 't':
31 secs_to_msecs = true; 35 secs_to_msecs = true;
32 break; 36 break;
33 default: 37 default:
34 print_usage = true; 38 print_usage = true;
35 break; 39 break;
36 } 40 }
37 } 41 }
38 name_index = optind; 42 name_index = optind;
39 } else { 43 } else {
40 print_usage = true; 44 print_usage = true;
41 } 45 }
42 46
43 if ((name_index + 5) != argc) { 47 int num_args = send_enum ? 3 : 5;
48 if ((name_index + num_args) != argc ||
49 (send_enum && secs_to_msecs)) {
44 print_usage = true; 50 print_usage = true;
45 } 51 }
46 52
47 if (print_usage) { 53 if (print_usage) {
48 fprintf(stderr, 54 fprintf(stderr,
49 "Usage: metrics_client [-abt] name sample min max nbuckets\n" 55 "Usage: metrics_client [-ab] [-t] name sample min max nbuckets\n"
56 " metrics_client [-ab] -e name sample max\n"
50 "\n" 57 "\n"
51 " default: send metric with integer values to Chrome only\n" 58 " default: send metric with integer values to Chrome only\n"
52 " -a: send metric to autotest only (min/max/nbuckets ignored)\n" 59 " |min| > 0, |min| <= sample < |max|\n"
53 " -b: send metric to both chrome and autotest\n" 60 " -a: send metric (name/sample) to Autotest only\n"
61 " -b: send metric to both Chrome and Autotest\n"
62 " -e: send linear/enumeration histogram data\n"
54 " -t: convert sample from double seconds to int milliseconds\n"); 63 " -t: convert sample from double seconds to int milliseconds\n");
55 return 1; 64 return 1;
56 } 65 }
57 66
58 const char* name = argv[name_index]; 67 const char* name = argv[name_index];
59 int sample; 68 int sample;
60 if (secs_to_msecs) { 69 if (secs_to_msecs) {
61 sample = static_cast<int>(atof(argv[name_index + 1]) * 1000.0); 70 sample = static_cast<int>(atof(argv[name_index + 1]) * 1000.0);
62 } else { 71 } else {
63 sample = atoi(argv[name_index + 1]); 72 sample = atoi(argv[name_index + 1]);
64 } 73 }
65 int min = atoi(argv[name_index + 2]);
66 int max = atoi(argv[name_index + 3]);
67 int nbuckets = atoi(argv[name_index + 4]);
68 74
69 // Send metrics 75 // Send metrics
70 if (send_to_autotest) { 76 if (send_to_autotest) {
71 MetricsLibrary::SendToAutotest(name, sample); 77 MetricsLibrary::SendToAutotest(name, sample);
72 } 78 }
79
73 if (send_to_chrome) { 80 if (send_to_chrome) {
74 MetricsLibrary::SendToChrome(name, sample, min, max, nbuckets); 81 if (send_enum) {
82 int max = atoi(argv[name_index + 2]);
83 MetricsLibrary::SendEnumToChrome(name, sample, max);
84 } else {
85 int min = atoi(argv[name_index + 2]);
86 int max = atoi(argv[name_index + 3]);
87 int nbuckets = atoi(argv[name_index + 4]);
88 MetricsLibrary::SendToChrome(name, sample, min, max, nbuckets);
89 }
75 } 90 }
76 return 0; 91 return 0;
77 } 92 }
OLDNEW
« no previous file with comments | « no previous file | src/platform/metrics/metrics_library.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698