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

Unified Diff: src/platform/metrics/metrics_client.cc

Issue 1649007: metrics cleanup and fixes. (Closed)
Patch Set: Expose the pass/fail status. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/platform/init/dump-boot-stats.conf ('k') | src/platform/metrics/metrics_daemon.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/platform/metrics/metrics_client.cc
diff --git a/src/platform/metrics/metrics_client.cc b/src/platform/metrics/metrics_client.cc
index cdea0124c64a580c4e21c976aa116b7294f51a23..17f933cbb37b499e5b88a8603e4a5872eb1a7cda 100644
--- a/src/platform/metrics/metrics_client.cc
+++ b/src/platform/metrics/metrics_client.cc
@@ -2,22 +2,16 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include <errno.h>
-#include <sys/file.h>
-#include <string.h>
-#include <stdio.h>
-
+#include <cstdio>
#include <cstdlib>
-#include <iostream>
#include "metrics_library.h"
-using namespace std;
-
// Usage: metrics_client [-ab] metric_name metric_value
int main(int argc, char** argv) {
bool send_to_autotest = false;
bool send_to_chrome = true;
+ bool secs_to_msecs = false;
int metric_name_index = 1;
int metric_value_index = 2;
bool print_usage = false;
@@ -25,7 +19,7 @@ int main(int argc, char** argv) {
if (argc >= 3) {
// Parse arguments
int flag;
- while ((flag = getopt(argc, argv, "ab")) != -1) {
+ while ((flag = getopt(argc, argv, "abt")) != -1) {
switch (flag) {
case 'a':
send_to_autotest = true;
@@ -35,6 +29,9 @@ int main(int argc, char** argv) {
send_to_chrome = true;
send_to_autotest = true;
break;
+ case 't':
+ secs_to_msecs = true;
+ break;
default:
print_usage = true;
break;
@@ -52,22 +49,31 @@ int main(int argc, char** argv) {
}
if (print_usage) {
- cerr << "Usage: metrics_client [-ab] name value" << endl;
- cerr << endl;
- cerr << " default: send metric to chrome only" << endl;
- cerr << " -a: send metric to autotest only" << endl;
- cerr << " -b: send metric to both chrome and autotest" << endl;
+ fprintf(stderr,
+ "Usage: metrics_client [-abt] name value\n"
+ "\n"
+ " default: send metric with integer value to chrome only\n"
+ " -a: send metric to autotest only\n"
+ " -b: send metric to both chrome and autotest\n"
+ " -t: convert value from float seconds to int milliseconds\n");
return 1;
}
+ const char* name = argv[metric_name_index];
+ int value;
+ if (secs_to_msecs) {
+ float secs = strtof(argv[metric_value_index], NULL);
+ value = static_cast<int>(secs * 1000.0f);
+ } else {
+ value = atoi(argv[metric_value_index]);
+ }
+
// Send metrics
if (send_to_autotest) {
- MetricsLibrary::SendToAutotest(argv[metric_name_index],
- argv[metric_value_index]);
+ MetricsLibrary::SendToAutotest(name, value);
}
if (send_to_chrome) {
- MetricsLibrary::SendToChrome(argv[metric_name_index],
- argv[metric_value_index]);
+ MetricsLibrary::SendToChrome(name, value);
}
return 0;
}
« no previous file with comments | « src/platform/init/dump-boot-stats.conf ('k') | src/platform/metrics/metrics_daemon.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698