Commit 80b8a3c1 authored by titzer's avatar titzer Committed by Commit bot

Add --dump-counters-nvp option for easier parsing of counter output.

R=jochen@chromium.org, hpayer@chromium.org, verwaest@chromium.org
BUG=

Review-Url: https://codereview.chromium.org/2584563002
Cr-Commit-Position: refs/heads/master@{#41729}
parent 2ff59062
......@@ -1688,7 +1688,7 @@ void Shell::WriteIgnitionDispatchCountersFile(v8::Isolate* isolate) {
void Shell::OnExit(v8::Isolate* isolate) {
if (i::FLAG_dump_counters) {
if (i::FLAG_dump_counters || i::FLAG_dump_counters_nvp) {
int number_of_counters = 0;
for (CounterMap::Iterator i(counter_map_); i.More(); i.Next()) {
number_of_counters++;
......@@ -1700,24 +1700,44 @@ void Shell::OnExit(v8::Isolate* isolate) {
counters[j].key = i.CurrentKey();
}
std::sort(counters, counters + number_of_counters);
printf("+----------------------------------------------------------------+"
"-------------+\n");
printf("| Name |"
" Value |\n");
printf("+----------------------------------------------------------------+"
"-------------+\n");
for (j = 0; j < number_of_counters; j++) {
Counter* counter = counters[j].counter;
const char* key = counters[j].key;
if (counter->is_histogram()) {
printf("| c:%-60s | %11i |\n", key, counter->count());
printf("| t:%-60s | %11i |\n", key, counter->sample_total());
} else {
printf("| %-62s | %11i |\n", key, counter->count());
if (i::FLAG_dump_counters_nvp) {
// Dump counters as name-value pairs.
for (j = 0; j < number_of_counters; j++) {
Counter* counter = counters[j].counter;
const char* key = counters[j].key;
if (counter->is_histogram()) {
printf("\"c:%s\"=%i\n", key, counter->count());
printf("\"t:%s\"=%i\n", key, counter->sample_total());
} else {
printf("\"%s\"=%i\n", key, counter->count());
}
}
} else {
// Dump counters in formatted boxes.
printf(
"+----------------------------------------------------------------+"
"-------------+\n");
printf(
"| Name |"
" Value |\n");
printf(
"+----------------------------------------------------------------+"
"-------------+\n");
for (j = 0; j < number_of_counters; j++) {
Counter* counter = counters[j].counter;
const char* key = counters[j].key;
if (counter->is_histogram()) {
printf("| c:%-60s | %11i |\n", key, counter->count());
printf("| t:%-60s | %11i |\n", key, counter->sample_total());
} else {
printf("| %-62s | %11i |\n", key, counter->count());
}
}
printf(
"+----------------------------------------------------------------+"
"-------------+\n");
}
printf("+----------------------------------------------------------------+"
"-------------+\n");
delete [] counters;
}
......@@ -2963,7 +2983,7 @@ int Shell::Main(int argc, char* argv[]) {
base::SysInfo::AmountOfVirtualMemory());
Shell::counter_map_ = new CounterMap();
if (i::FLAG_dump_counters || i::FLAG_gc_stats) {
if (i::FLAG_dump_counters || i::FLAG_dump_counters_nvp || i::FLAG_gc_stats) {
create_params.counter_lookup_callback = LookupCounter;
create_params.create_histogram_callback = CreateHistogram;
create_params.add_histogram_sample_callback = AddHistogramSample;
......
......@@ -958,6 +958,8 @@ DEFINE_BOOL(disable_old_api_accessors, false,
DEFINE_BOOL(help, false, "Print usage message, including flags, on console")
DEFINE_BOOL(dump_counters, false, "Dump counters on exit")
DEFINE_BOOL(dump_counters_nvp, false,
"Dump counters as name-value pairs on exit")
DEFINE_STRING(map_counters, "", "Map counters to a file")
DEFINE_ARGS(js_arguments,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment