| 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 intptr_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 intptr_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 |
| 30 // Cumulative timer of flow graph builder, included in codegen_timer. |
| 31 Timer CompilerStats::graphbuilder_timer(true, "flow graph builder timer"); |
| 32 |
| 33 // Cumulative timer of flow graph compiler, included in codegen_timer. |
| 34 Timer CompilerStats::graphcompiler_timer(true, "flow graph compiler timer"); |
| 35 |
| 36 // Cumulative timer of code finalization, included in codegen_timer. |
| 37 Timer CompilerStats::codefinalizer_timer(true, "code finalization timer"); |
| 38 |
| 39 |
| 30 intptr_t CompilerStats::num_tokens_total = 0; | 40 intptr_t CompilerStats::num_tokens_total = 0; |
| 31 intptr_t CompilerStats::num_literal_tokens_total = 0; | 41 intptr_t CompilerStats::num_literal_tokens_total = 0; |
| 32 intptr_t CompilerStats::num_ident_tokens_total = 0; | 42 intptr_t CompilerStats::num_ident_tokens_total = 0; |
| 33 intptr_t CompilerStats::num_tokens_consumed = 0; | 43 intptr_t CompilerStats::num_tokens_consumed = 0; |
| 34 intptr_t CompilerStats::num_token_checks = 0; | 44 intptr_t CompilerStats::num_token_checks = 0; |
| 35 intptr_t CompilerStats::num_tokens_rewind = 0; | 45 intptr_t CompilerStats::num_tokens_rewind = 0; |
| 36 intptr_t CompilerStats::num_tokens_lookahead = 0; | 46 intptr_t CompilerStats::num_tokens_lookahead = 0; |
| 37 | 47 |
| 38 void CompilerStats::Print() { | 48 void CompilerStats::Print() { |
| 39 if (!FLAG_compiler_stats) { | 49 if (!FLAG_compiler_stats) { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 56 OS::Print("Source length: %ld characters\n", src_length); | 66 OS::Print("Source length: %ld characters\n", src_length); |
| 57 intptr_t scan_usecs = scanner_timer.TotalElapsedTime(); | 67 intptr_t scan_usecs = scanner_timer.TotalElapsedTime(); |
| 58 OS::Print("Scanner time: %ld msecs\n", | 68 OS::Print("Scanner time: %ld msecs\n", |
| 59 scan_usecs / 1000); | 69 scan_usecs / 1000); |
| 60 intptr_t parse_usecs = parser_timer.TotalElapsedTime(); | 70 intptr_t parse_usecs = parser_timer.TotalElapsedTime(); |
| 61 OS::Print("Parser time: %ld msecs\n", | 71 OS::Print("Parser time: %ld msecs\n", |
| 62 parse_usecs / 1000); | 72 parse_usecs / 1000); |
| 63 intptr_t codegen_usecs = codegen_timer.TotalElapsedTime(); | 73 intptr_t codegen_usecs = codegen_timer.TotalElapsedTime(); |
| 64 OS::Print("Code gen. time: %ld msecs\n", | 74 OS::Print("Code gen. time: %ld msecs\n", |
| 65 codegen_usecs / 1000); | 75 codegen_usecs / 1000); |
| 76 intptr_t graphbuilder_usecs = graphbuilder_timer.TotalElapsedTime(); |
| 77 OS::Print(" Graph builder time: %ld msecs\n", graphbuilder_usecs / 1000); |
| 78 intptr_t graphcompiler_usecs = graphcompiler_timer.TotalElapsedTime(); |
| 79 OS::Print(" Graph comp. time: %ld msecs\n", graphcompiler_usecs / 1000); |
| 80 intptr_t codefinalizer_usecs = codefinalizer_timer.TotalElapsedTime(); |
| 81 OS::Print(" Code final. time: %ld msecs\n", codefinalizer_usecs / 1000); |
| 66 OS::Print("Compilation speed: %ld tokens per msec\n", | 82 OS::Print("Compilation speed: %ld tokens per msec\n", |
| 67 1000 * num_tokens_total / (parse_usecs + codegen_usecs)); | 83 1000 * num_tokens_total / (parse_usecs + codegen_usecs)); |
| 68 OS::Print("Code size: %ld KB\n", | 84 OS::Print("Code size: %ld KB\n", |
| 69 code_allocated / 1024); | 85 code_allocated / 1024); |
| 70 OS::Print("Code density: %ld tokens per KB\n", | 86 OS::Print("Code density: %ld tokens per KB\n", |
| 71 num_tokens_total * 1024 / code_allocated); | 87 num_tokens_total * 1024 / code_allocated); |
| 72 } | 88 } |
| 73 | 89 |
| 74 } // namespace dart | 90 } // namespace dart |
| OLD | NEW |