OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 776 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
787 void Shell::Exit(int exit_code) { | 787 void Shell::Exit(int exit_code) { |
788 // Use _exit instead of exit to avoid races between isolate | 788 // Use _exit instead of exit to avoid races between isolate |
789 // threads and static destructors. | 789 // threads and static destructors. |
790 fflush(stdout); | 790 fflush(stdout); |
791 fflush(stderr); | 791 fflush(stderr); |
792 _exit(exit_code); | 792 _exit(exit_code); |
793 } | 793 } |
794 | 794 |
795 | 795 |
796 #ifndef V8_SHARED | 796 #ifndef V8_SHARED |
| 797 struct CounterAndKey { |
| 798 Counter* counter; |
| 799 const char* key; |
| 800 }; |
| 801 |
| 802 |
| 803 int CompareKeys(const void* a, const void* b) { |
| 804 return strcmp(static_cast<const CounterAndKey*>(a)->key, |
| 805 static_cast<const CounterAndKey*>(b)->key); |
| 806 } |
| 807 |
| 808 |
797 void Shell::OnExit() { | 809 void Shell::OnExit() { |
798 if (console != NULL) console->Close(); | 810 if (console != NULL) console->Close(); |
799 if (i::FLAG_dump_counters) { | 811 if (i::FLAG_dump_counters) { |
800 printf("+----------------------------------------+-------------+\n"); | 812 int number_of_counters = 0; |
801 printf("| Name | Value |\n"); | |
802 printf("+----------------------------------------+-------------+\n"); | |
803 for (CounterMap::Iterator i(counter_map_); i.More(); i.Next()) { | 813 for (CounterMap::Iterator i(counter_map_); i.More(); i.Next()) { |
804 Counter* counter = i.CurrentValue(); | 814 number_of_counters++; |
| 815 } |
| 816 CounterAndKey* counters = new CounterAndKey[number_of_counters]; |
| 817 int j = 0; |
| 818 for (CounterMap::Iterator i(counter_map_); i.More(); i.Next(), j++) { |
| 819 counters[j].counter = i.CurrentValue(); |
| 820 counters[j].key = i.CurrentKey(); |
| 821 } |
| 822 qsort(counters, number_of_counters, sizeof(counters[0]), CompareKeys); |
| 823 printf("+--------------------------------------------+-------------+\n"); |
| 824 printf("| Name | Value |\n"); |
| 825 printf("+--------------------------------------------+-------------+\n"); |
| 826 for (j = 0; j < number_of_counters; j++) { |
| 827 Counter* counter = counters[j].counter; |
| 828 const char* key = counters[j].key; |
805 if (counter->is_histogram()) { | 829 if (counter->is_histogram()) { |
806 printf("| c:%-36s | %11i |\n", i.CurrentKey(), counter->count()); | 830 printf("| c:%-40s | %11i |\n", key, counter->count()); |
807 printf("| t:%-36s | %11i |\n", i.CurrentKey(), counter->sample_total()); | 831 printf("| t:%-40s | %11i |\n", key, counter->sample_total()); |
808 } else { | 832 } else { |
809 printf("| %-38s | %11i |\n", i.CurrentKey(), counter->count()); | 833 printf("| %-42s | %11i |\n", key, counter->count()); |
810 } | 834 } |
811 } | 835 } |
812 printf("+----------------------------------------+-------------+\n"); | 836 printf("+--------------------------------------------+-------------+\n"); |
| 837 delete [] counters; |
813 } | 838 } |
814 if (counters_file_ != NULL) | 839 if (counters_file_ != NULL) |
815 delete counters_file_; | 840 delete counters_file_; |
816 } | 841 } |
817 #endif // V8_SHARED | 842 #endif // V8_SHARED |
818 | 843 |
819 | 844 |
820 static FILE* FOpen(const char* path, const char* mode) { | 845 static FILE* FOpen(const char* path, const char* mode) { |
821 #if defined(_MSC_VER) && (defined(_WIN32) || defined(_WIN64)) | 846 #if defined(_MSC_VER) && (defined(_WIN32) || defined(_WIN64)) |
822 FILE* result; | 847 FILE* result; |
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1356 } | 1381 } |
1357 | 1382 |
1358 } // namespace v8 | 1383 } // namespace v8 |
1359 | 1384 |
1360 | 1385 |
1361 #ifndef GOOGLE3 | 1386 #ifndef GOOGLE3 |
1362 int main(int argc, char* argv[]) { | 1387 int main(int argc, char* argv[]) { |
1363 return v8::Shell::Main(argc, argv); | 1388 return v8::Shell::Main(argc, argv); |
1364 } | 1389 } |
1365 #endif | 1390 #endif |
OLD | NEW |