OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "vm/compiler_stats.h" | 5 #include "vm/compiler_stats.h" |
6 | 6 |
7 #include "vm/flags.h" | 7 #include "vm/flags.h" |
8 #include "vm/timer.h" | 8 #include "vm/timer.h" |
9 | 9 |
10 | 10 |
11 namespace dart { | 11 namespace dart { |
12 | 12 |
13 DEFINE_FLAG(bool, compiler_stats, false, "Compiler stat counters."); | 13 DEFINE_FLAG(bool, compiler_stats, false, "Compiler stat counters."); |
14 | 14 |
15 // Bytes allocated for generated code. | 15 // Bytes allocated for generated code. |
16 intptr_t CompilerStats::code_allocated = 0; | 16 int64_t CompilerStats::code_allocated = 0; |
17 | 17 |
18 // Total number of characters in source. | 18 // Total number of characters in source. |
19 intptr_t CompilerStats::src_length = 0; | 19 int64_t CompilerStats::src_length = 0; |
20 | 20 |
21 // Cumulative runtime of parser. | 21 // Cumulative runtime of parser. |
22 Timer CompilerStats::parser_timer(true, "parser timer"); | 22 Timer CompilerStats::parser_timer(true, "parser timer"); |
23 | 23 |
24 // Cumulative runtime of scanner. | 24 // Cumulative runtime of scanner. |
25 Timer CompilerStats::scanner_timer(true, "scanner timer"); | 25 Timer CompilerStats::scanner_timer(true, "scanner timer"); |
26 | 26 |
27 // Cumulative runtime of code generator. | 27 // Cumulative runtime of code generator. |
28 Timer CompilerStats::codegen_timer(true, "codegen timer"); | 28 Timer CompilerStats::codegen_timer(true, "codegen timer"); |
29 | 29 |
(...skipping 16 matching lines...) Expand all Loading... |
46 // Cumulative timer of flow graph optimizer, included in codegen_timer. | 46 // Cumulative timer of flow graph optimizer, included in codegen_timer. |
47 Timer CompilerStats::graphoptimizer_timer(true, "flow graph optimizer timer"); | 47 Timer CompilerStats::graphoptimizer_timer(true, "flow graph optimizer timer"); |
48 | 48 |
49 // Cumulative timer of flow graph compiler, included in codegen_timer. | 49 // Cumulative timer of flow graph compiler, included in codegen_timer. |
50 Timer CompilerStats::graphcompiler_timer(true, "flow graph compiler timer"); | 50 Timer CompilerStats::graphcompiler_timer(true, "flow graph compiler timer"); |
51 | 51 |
52 // Cumulative timer of code finalization, included in codegen_timer. | 52 // Cumulative timer of code finalization, included in codegen_timer. |
53 Timer CompilerStats::codefinalizer_timer(true, "code finalization timer"); | 53 Timer CompilerStats::codefinalizer_timer(true, "code finalization timer"); |
54 | 54 |
55 | 55 |
56 intptr_t CompilerStats::num_tokens_total = 0; | 56 int64_t CompilerStats::num_tokens_total = 0; |
57 intptr_t CompilerStats::num_literal_tokens_total = 0; | 57 int64_t CompilerStats::num_literal_tokens_total = 0; |
58 intptr_t CompilerStats::num_ident_tokens_total = 0; | 58 int64_t CompilerStats::num_ident_tokens_total = 0; |
59 intptr_t CompilerStats::num_tokens_consumed = 0; | 59 int64_t CompilerStats::num_tokens_consumed = 0; |
60 intptr_t CompilerStats::num_token_checks = 0; | 60 int64_t CompilerStats::num_token_checks = 0; |
61 intptr_t CompilerStats::num_tokens_rewind = 0; | 61 int64_t CompilerStats::num_tokens_rewind = 0; |
62 intptr_t CompilerStats::num_tokens_lookahead = 0; | 62 int64_t CompilerStats::num_tokens_lookahead = 0; |
63 | 63 |
64 intptr_t CompilerStats::num_lib_cache_hit = 0; | 64 int64_t CompilerStats::num_lib_cache_hit = 0; |
65 intptr_t CompilerStats::num_names_cached = 0; | 65 int64_t CompilerStats::num_names_cached = 0; |
66 intptr_t CompilerStats::make_accessor_name = 0; | 66 int64_t CompilerStats::make_accessor_name = 0; |
67 intptr_t CompilerStats::make_field_name = 0; | 67 int64_t CompilerStats::make_field_name = 0; |
68 | 68 |
69 intptr_t CompilerStats::num_classes_compiled = 0; | 69 int64_t CompilerStats::num_classes_compiled = 0; |
70 intptr_t CompilerStats::num_functions_compiled = 0; | 70 int64_t CompilerStats::num_functions_compiled = 0; |
71 | 71 |
72 intptr_t CompilerStats::num_implicit_final_getters = 0; | 72 int64_t CompilerStats::num_implicit_final_getters = 0; |
73 intptr_t CompilerStats::num_static_initializer_funcs = 0; | 73 int64_t CompilerStats::num_static_initializer_funcs = 0; |
74 | 74 |
75 void CompilerStats::Print() { | 75 void CompilerStats::Print() { |
76 if (!FLAG_compiler_stats) { | 76 if (!FLAG_compiler_stats) { |
77 return; | 77 return; |
78 } | 78 } |
79 OS::Print("==== Compiler Stats ====\n"); | 79 OS::Print("==== Compiler Stats ====\n"); |
80 OS::Print("Number of tokens: %" Pd "\n", num_tokens_total); | 80 OS::Print("Number of tokens: %" Pd64 "\n", num_tokens_total); |
81 OS::Print(" Literal tokens: %" Pd "\n", num_literal_tokens_total); | 81 OS::Print(" Literal tokens: %" Pd64 "\n", num_literal_tokens_total); |
82 OS::Print(" Ident tokens: %" Pd "\n", num_ident_tokens_total); | 82 OS::Print(" Ident tokens: %" Pd64 "\n", num_ident_tokens_total); |
83 OS::Print("Tokens consumed: %" Pd " (%.2f times number of tokens)\n", | 83 OS::Print("Tokens consumed: %" Pd64 " (%.2f times number of tokens)\n", |
84 num_tokens_consumed, | 84 num_tokens_consumed, |
85 (1.0 * num_tokens_consumed) / num_tokens_total); | 85 (1.0 * num_tokens_consumed) / num_tokens_total); |
86 OS::Print("Tokens checked: %" Pd " (%.2f times tokens consumed)\n", | 86 OS::Print("Tokens checked: %" Pd64 " (%.2f times tokens consumed)\n", |
87 num_token_checks, (1.0 * num_token_checks) / num_tokens_consumed); | 87 num_token_checks, (1.0 * num_token_checks) / num_tokens_consumed); |
88 OS::Print("Token rewind: %" Pd " (%" Pd "%% of tokens checked)\n", | 88 OS::Print("Token rewind: %" Pd64 " (%" Pd64 "%% of tokens checked)\n", |
89 num_tokens_rewind, (100 * num_tokens_rewind) / num_token_checks); | 89 num_tokens_rewind, (100 * num_tokens_rewind) / num_token_checks); |
90 OS::Print("Token lookahead: %" Pd " (%" Pd "%% of tokens checked)\n", | 90 OS::Print("Token lookahead: %" Pd64 " (%" Pd64 "%% of tokens checked)\n", |
91 num_tokens_lookahead, | 91 num_tokens_lookahead, |
92 (100 * num_tokens_lookahead) / num_token_checks); | 92 (100 * num_tokens_lookahead) / num_token_checks); |
93 | 93 |
94 OS::Print("Classes parsed: %" Pd "\n", num_classes_compiled); | 94 OS::Print("Classes parsed: %" Pd64 "\n", num_classes_compiled); |
95 OS::Print("Functions compiled: %" Pd "\n", num_functions_compiled); | 95 OS::Print("Functions compiled: %" Pd64 "\n", num_functions_compiled); |
96 OS::Print(" Impl getters: %" Pd "\n", num_implicit_final_getters); | 96 OS::Print(" Impl getters: %" Pd64 "\n", num_implicit_final_getters); |
97 OS::Print(" Init funcs: %" Pd "\n", num_static_initializer_funcs); | 97 OS::Print(" Init funcs: %" Pd64 "\n", num_static_initializer_funcs); |
98 | 98 |
99 OS::Print("Lib names cached: %" Pd "\n", num_names_cached); | 99 OS::Print("Lib names cached: %" Pd64 "\n", num_names_cached); |
100 OS::Print("Lib name cache hit: %" Pd "\n", num_lib_cache_hit); | 100 OS::Print("Lib name cache hit: %" Pd64 "\n", num_lib_cache_hit); |
101 OS::Print("Accessor mangling: %" Pd " field->acc %" Pd " acc->field\n", | 101 OS::Print("Accessor mangling: %" Pd64 " field->acc %" Pd64 " acc->field\n", |
102 make_accessor_name, make_field_name); | 102 make_accessor_name, make_field_name); |
103 | 103 |
104 OS::Print("Source length: %" Pd " characters\n", src_length); | 104 OS::Print("Source length: %" Pd64 " characters\n", src_length); |
105 int64_t scan_usecs = scanner_timer.TotalElapsedTime(); | 105 int64_t scan_usecs = scanner_timer.TotalElapsedTime(); |
106 OS::Print("Scanner time: %" Pd64 " msecs\n", | 106 OS::Print("Scanner time: %" Pd64 " msecs\n", |
107 scan_usecs / 1000); | 107 scan_usecs / 1000); |
108 int64_t parse_usecs = parser_timer.TotalElapsedTime(); | 108 int64_t parse_usecs = parser_timer.TotalElapsedTime(); |
109 OS::Print("Parser time: %" Pd64 " msecs\n", | 109 OS::Print("Parser time: %" Pd64 " msecs\n", |
110 parse_usecs / 1000); | 110 parse_usecs / 1000); |
111 int64_t codegen_usecs = codegen_timer.TotalElapsedTime(); | 111 int64_t codegen_usecs = codegen_timer.TotalElapsedTime(); |
112 OS::Print("Code gen. time: %" Pd64 " msecs\n", | 112 OS::Print("Code gen. time: %" Pd64 " msecs\n", |
113 codegen_usecs / 1000); | 113 codegen_usecs / 1000); |
114 int64_t graphbuilder_usecs = graphbuilder_timer.TotalElapsedTime(); | 114 int64_t graphbuilder_usecs = graphbuilder_timer.TotalElapsedTime(); |
(...skipping 25 matching lines...) Expand all Loading... |
140 int64_t graphoptimizer_usecs = graphoptimizer_timer.TotalElapsedTime(); | 140 int64_t graphoptimizer_usecs = graphoptimizer_timer.TotalElapsedTime(); |
141 OS::Print(" Graph optimizer: %" Pd64 " msecs\n", | 141 OS::Print(" Graph optimizer: %" Pd64 " msecs\n", |
142 (graphoptimizer_usecs - graphinliner_usecs) / 1000); | 142 (graphoptimizer_usecs - graphinliner_usecs) / 1000); |
143 int64_t graphcompiler_usecs = graphcompiler_timer.TotalElapsedTime(); | 143 int64_t graphcompiler_usecs = graphcompiler_timer.TotalElapsedTime(); |
144 OS::Print(" Graph compiler: %" Pd64 " msecs\n", | 144 OS::Print(" Graph compiler: %" Pd64 " msecs\n", |
145 graphcompiler_usecs / 1000); | 145 graphcompiler_usecs / 1000); |
146 int64_t codefinalizer_usecs = codefinalizer_timer.TotalElapsedTime(); | 146 int64_t codefinalizer_usecs = codefinalizer_timer.TotalElapsedTime(); |
147 OS::Print(" Code finalizer: %" Pd64 " msecs\n", | 147 OS::Print(" Code finalizer: %" Pd64 " msecs\n", |
148 codefinalizer_usecs / 1000); | 148 codefinalizer_usecs / 1000); |
149 OS::Print("Compilation speed: %" Pd64 " tokens per msec\n", | 149 OS::Print("Compilation speed: %" Pd64 " tokens per msec\n", |
150 1000 * num_tokens_total / (parse_usecs + codegen_usecs)); | 150 (1000 * num_tokens_total) / (parse_usecs + codegen_usecs)); |
151 OS::Print("Code size: %" Pd " KB\n", | 151 OS::Print("Code size: %" Pd64 " KB\n", |
152 code_allocated / 1024); | 152 code_allocated / 1024); |
153 OS::Print("Code density: %" Pd " tokens per KB\n", | 153 OS::Print("Code density: %" Pd64 " tokens per KB\n", |
154 num_tokens_total * 1024 / code_allocated); | 154 (num_tokens_total * 1024) / code_allocated); |
155 } | 155 } |
156 | 156 |
157 } // namespace dart | 157 } // namespace dart |
OLD | NEW |