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

Unified Diff: src/d8.cc

Issue 8720005: Dump counters sorted by name on d8 exit. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 1 month 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/d8.cc
diff --git a/src/d8.cc b/src/d8.cc
index 64ada2c2456dc4d331449b9962e95b45bc7b1a57..9eccc7e4fe4ed6fd0786c0bbeb62a06ffb277498 100644
--- a/src/d8.cc
+++ b/src/d8.cc
@@ -794,22 +794,47 @@ void Shell::Exit(int exit_code) {
#ifndef V8_SHARED
+struct CounterAndKey {
+ Counter* counter;
+ const char* key;
+};
+
+
+int CompareKeys(const void* a, const void* b) {
+ return strcmp(static_cast<const CounterAndKey*>(a)->key,
+ static_cast<const CounterAndKey*>(b)->key);
+}
+
+
void Shell::OnExit() {
if (console != NULL) console->Close();
if (i::FLAG_dump_counters) {
- printf("+----------------------------------------+-------------+\n");
- printf("| Name | Value |\n");
- printf("+----------------------------------------+-------------+\n");
+ int number_of_counters = 0;
for (CounterMap::Iterator i(counter_map_); i.More(); i.Next()) {
- Counter* counter = i.CurrentValue();
+ number_of_counters++;
+ }
+ CounterAndKey* counters = new CounterAndKey[number_of_counters];
+ int j = 0;
+ for (CounterMap::Iterator i(counter_map_); i.More(); i.Next(), j++) {
+ counters[j].counter = i.CurrentValue();
+ counters[j].key = i.CurrentKey();
+ }
+ qsort(counters, number_of_counters, sizeof(counters[0]), CompareKeys);
+ 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:%-36s | %11i |\n", i.CurrentKey(), counter->count());
- printf("| t:%-36s | %11i |\n", i.CurrentKey(), counter->sample_total());
+ printf("| c:%-40s | %11i |\n", key, counter->count());
+ printf("| t:%-40s | %11i |\n", key, counter->sample_total());
} else {
- printf("| %-38s | %11i |\n", i.CurrentKey(), counter->count());
+ printf("| %-42s | %11i |\n", key, counter->count());
}
}
- printf("+----------------------------------------+-------------+\n");
+ printf("+--------------------------------------------+-------------+\n");
+ delete [] counters;
}
if (counters_file_ != NULL)
delete counters_file_;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698