OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # | 2 # |
3 # Copyright 2012 the V8 project authors. All rights reserved. | 3 # Copyright 2012 the V8 project authors. All rights reserved. |
4 # Redistribution and use in source and binary forms, with or without | 4 # Redistribution and use in source and binary forms, with or without |
5 # modification, are permitted provided that the following conditions are | 5 # modification, are permitted provided that the following conditions are |
6 # met: | 6 # met: |
7 # | 7 # |
8 # * Redistributions of source code must retain the above copyright | 8 # * Redistributions of source code must retain the above copyright |
9 # notice, this list of conditions and the following disclaimer. | 9 # notice, this list of conditions and the following disclaimer. |
10 # * Redistributions in binary form must reproduce the above | 10 # * Redistributions in binary form must reproduce the above |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 # Ticks (reported pc values) are not always precise, i.e. not | 166 # Ticks (reported pc values) are not always precise, i.e. not |
167 # necessarily point at instruction starts. So we have to search | 167 # necessarily point at instruction starts. So we have to search |
168 # for ticks that touch the current instruction line. | 168 # for ticks that touch the current instruction line. |
169 j = bisect.bisect_left(ticks_offsets, end_offset) | 169 j = bisect.bisect_left(ticks_offsets, end_offset) |
170 count = 0 | 170 count = 0 |
171 for offset, cnt in reversed(zip(ticks_offsets[:j], ticks_counts[:j])): | 171 for offset, cnt in reversed(zip(ticks_offsets[:j], ticks_counts[:j])): |
172 if offset < start_offset: | 172 if offset < start_offset: |
173 break | 173 break |
174 count += cnt | 174 count += cnt |
175 total_count += count | 175 total_count += count |
176 count = 100.0 * count / self.self_ticks | 176 percent = 100.0 * count / self.self_ticks |
177 if count >= 0.01: | 177 offset = lines[i][0] |
178 print "%15.2f %x: %s" % (count, lines[i][0], lines[i][1]) | 178 if percent >= 0.01: |
| 179 # 5 spaces for tick count |
| 180 # 1 space following |
| 181 # 1 for '|' |
| 182 # 1 space following |
| 183 # 6 for the percentage number, incl. the '.' |
| 184 # 1 for the '%' sign |
| 185 # => 15 |
| 186 print "%5d | %6.2f%% %x: %s" % (count, percent, offset, lines[i][1]) |
179 else: | 187 else: |
180 print "%s %x: %s" % (" " * 15, lines[i][0], lines[i][1]) | 188 print "%s %x: %s" % (" " * 15, offset, lines[i][1]) |
181 print | 189 print |
182 assert total_count == self.self_ticks, \ | 190 assert total_count == self.self_ticks, \ |
183 "Lost ticks (%d != %d) in %s" % (total_count, self.self_ticks, self) | 191 "Lost ticks (%d != %d) in %s" % (total_count, self.self_ticks, self) |
184 | 192 |
185 def __str__(self): | 193 def __str__(self): |
186 return "%s [0x%x, 0x%x) size: %d origin: %s" % ( | 194 return "%s [0x%x, 0x%x) size: %d origin: %s" % ( |
187 self.name, | 195 self.name, |
188 self.start_address, | 196 self.start_address, |
189 self.end_address, | 197 self.end_address, |
190 self.end_address - self.start_address, | 198 self.end_address - self.start_address, |
(...skipping 861 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1052 PrintTicks(optimized_ticks, ticks, "ticks in optimized code") | 1060 PrintTicks(optimized_ticks, ticks, "ticks in optimized code") |
1053 PrintTicks(generated_ticks, ticks, "ticks in other lazily compiled code") | 1061 PrintTicks(generated_ticks, ticks, "ticks in other lazily compiled code") |
1054 PrintTicks(v8_internal_ticks, ticks, "ticks in v8::internal::*") | 1062 PrintTicks(v8_internal_ticks, ticks, "ticks in v8::internal::*") |
1055 print "%10d total symbols" % len([c for c in code_map.AllCode()]) | 1063 print "%10d total symbols" % len([c for c in code_map.AllCode()]) |
1056 print "%10d used symbols" % len([c for c in code_map.UsedCode()]) | 1064 print "%10d used symbols" % len([c for c in code_map.UsedCode()]) |
1057 print "%9.2fs library processing time" % mmap_time | 1065 print "%9.2fs library processing time" % mmap_time |
1058 print "%9.2fs tick processing time" % sample_time | 1066 print "%9.2fs tick processing time" % sample_time |
1059 | 1067 |
1060 log_reader.Dispose() | 1068 log_reader.Dispose() |
1061 trace_reader.Dispose() | 1069 trace_reader.Dispose() |
OLD | NEW |