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

Side by Side Diff: src/d8.cc

Issue 2584563002: Add --dump-counters-nvp option for easier parsing of counter output. (Closed)
Patch Set: Created 4 years 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/flag-definitions.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project 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 <errno.h> 5 #include <errno.h>
6 #include <stdlib.h> 6 #include <stdlib.h>
7 #include <string.h> 7 #include <string.h>
8 #include <sys/stat.h> 8 #include <sys/stat.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 1670 matching lines...) Expand 10 before | Expand all | Expand 10 after
1681 ->interpreter() 1681 ->interpreter()
1682 ->GetDispatchCountersObject(); 1682 ->GetDispatchCountersObject();
1683 std::ofstream dispatch_counters_stream( 1683 std::ofstream dispatch_counters_stream(
1684 i::FLAG_trace_ignition_dispatches_output_file); 1684 i::FLAG_trace_ignition_dispatches_output_file);
1685 dispatch_counters_stream << *String::Utf8Value( 1685 dispatch_counters_stream << *String::Utf8Value(
1686 JSON::Stringify(context, dispatch_counters).ToLocalChecked()); 1686 JSON::Stringify(context, dispatch_counters).ToLocalChecked());
1687 } 1687 }
1688 1688
1689 1689
1690 void Shell::OnExit(v8::Isolate* isolate) { 1690 void Shell::OnExit(v8::Isolate* isolate) {
1691 if (i::FLAG_dump_counters) { 1691 if (i::FLAG_dump_counters || i::FLAG_dump_counters_nvp) {
1692 int number_of_counters = 0; 1692 int number_of_counters = 0;
1693 for (CounterMap::Iterator i(counter_map_); i.More(); i.Next()) { 1693 for (CounterMap::Iterator i(counter_map_); i.More(); i.Next()) {
1694 number_of_counters++; 1694 number_of_counters++;
1695 } 1695 }
1696 CounterAndKey* counters = new CounterAndKey[number_of_counters]; 1696 CounterAndKey* counters = new CounterAndKey[number_of_counters];
1697 int j = 0; 1697 int j = 0;
1698 for (CounterMap::Iterator i(counter_map_); i.More(); i.Next(), j++) { 1698 for (CounterMap::Iterator i(counter_map_); i.More(); i.Next(), j++) {
1699 counters[j].counter = i.CurrentValue(); 1699 counters[j].counter = i.CurrentValue();
1700 counters[j].key = i.CurrentKey(); 1700 counters[j].key = i.CurrentKey();
1701 } 1701 }
1702 std::sort(counters, counters + number_of_counters); 1702 std::sort(counters, counters + number_of_counters);
1703 printf("+----------------------------------------------------------------+" 1703
1704 "-------------+\n"); 1704 if (i::FLAG_dump_counters_nvp) {
1705 printf("| Name |" 1705 // Dump counters as name-value pairs.
1706 " Value |\n"); 1706 for (j = 0; j < number_of_counters; j++) {
1707 printf("+----------------------------------------------------------------+" 1707 Counter* counter = counters[j].counter;
1708 "-------------+\n"); 1708 const char* key = counters[j].key;
1709 for (j = 0; j < number_of_counters; j++) { 1709 if (counter->is_histogram()) {
1710 Counter* counter = counters[j].counter; 1710 printf("\"c:%s\"=%i\n", key, counter->count());
1711 const char* key = counters[j].key; 1711 printf("\"t:%s\"=%i\n", key, counter->sample_total());
1712 if (counter->is_histogram()) { 1712 } else {
1713 printf("| c:%-60s | %11i |\n", key, counter->count()); 1713 printf("\"%s\"=%i\n", key, counter->count());
1714 printf("| t:%-60s | %11i |\n", key, counter->sample_total()); 1714 }
1715 } else {
1716 printf("| %-62s | %11i |\n", key, counter->count());
1717 } 1715 }
1716 } else {
1717 // Dump counters in formatted boxes.
1718 printf(
1719 "+----------------------------------------------------------------+"
1720 "-------------+\n");
1721 printf(
1722 "| Name |"
1723 " Value |\n");
1724 printf(
1725 "+----------------------------------------------------------------+"
1726 "-------------+\n");
1727 for (j = 0; j < number_of_counters; j++) {
1728 Counter* counter = counters[j].counter;
1729 const char* key = counters[j].key;
1730 if (counter->is_histogram()) {
1731 printf("| c:%-60s | %11i |\n", key, counter->count());
1732 printf("| t:%-60s | %11i |\n", key, counter->sample_total());
1733 } else {
1734 printf("| %-62s | %11i |\n", key, counter->count());
1735 }
1736 }
1737 printf(
1738 "+----------------------------------------------------------------+"
1739 "-------------+\n");
1718 } 1740 }
1719 printf("+----------------------------------------------------------------+"
1720 "-------------+\n");
1721 delete [] counters; 1741 delete [] counters;
1722 } 1742 }
1723 1743
1724 delete counters_file_; 1744 delete counters_file_;
1725 delete counter_map_; 1745 delete counter_map_;
1726 } 1746 }
1727 1747
1728 1748
1729 1749
1730 static FILE* FOpen(const char* path, const char* mode) { 1750 static FILE* FOpen(const char* path, const char* mode) {
(...skipping 1225 matching lines...) Expand 10 before | Expand all | Expand 10 after
2956 } 2976 }
2957 create_params.array_buffer_allocator = Shell::array_buffer_allocator; 2977 create_params.array_buffer_allocator = Shell::array_buffer_allocator;
2958 #ifdef ENABLE_VTUNE_JIT_INTERFACE 2978 #ifdef ENABLE_VTUNE_JIT_INTERFACE
2959 create_params.code_event_handler = vTune::GetVtuneCodeEventHandler(); 2979 create_params.code_event_handler = vTune::GetVtuneCodeEventHandler();
2960 #endif 2980 #endif
2961 create_params.constraints.ConfigureDefaults( 2981 create_params.constraints.ConfigureDefaults(
2962 base::SysInfo::AmountOfPhysicalMemory(), 2982 base::SysInfo::AmountOfPhysicalMemory(),
2963 base::SysInfo::AmountOfVirtualMemory()); 2983 base::SysInfo::AmountOfVirtualMemory());
2964 2984
2965 Shell::counter_map_ = new CounterMap(); 2985 Shell::counter_map_ = new CounterMap();
2966 if (i::FLAG_dump_counters || i::FLAG_gc_stats) { 2986 if (i::FLAG_dump_counters || i::FLAG_dump_counters_nvp || i::FLAG_gc_stats) {
2967 create_params.counter_lookup_callback = LookupCounter; 2987 create_params.counter_lookup_callback = LookupCounter;
2968 create_params.create_histogram_callback = CreateHistogram; 2988 create_params.create_histogram_callback = CreateHistogram;
2969 create_params.add_histogram_sample_callback = AddHistogramSample; 2989 create_params.add_histogram_sample_callback = AddHistogramSample;
2970 } 2990 }
2971 2991
2972 Isolate* isolate = Isolate::New(create_params); 2992 Isolate* isolate = Isolate::New(create_params);
2973 { 2993 {
2974 Isolate::Scope scope(isolate); 2994 Isolate::Scope scope(isolate);
2975 Initialize(isolate); 2995 Initialize(isolate);
2976 PerIsolateData data(isolate); 2996 PerIsolateData data(isolate);
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
3058 } 3078 }
3059 3079
3060 } // namespace v8 3080 } // namespace v8
3061 3081
3062 3082
3063 #ifndef GOOGLE3 3083 #ifndef GOOGLE3
3064 int main(int argc, char* argv[]) { 3084 int main(int argc, char* argv[]) {
3065 return v8::Shell::Main(argc, argv); 3085 return v8::Shell::Main(argc, argv);
3066 } 3086 }
3067 #endif 3087 #endif
OLDNEW
« no previous file with comments | « no previous file | src/flag-definitions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698