| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # | 2 # |
| 3 # Copyright 2010 the V8 project authors. All rights reserved. | 3 # Copyright 2010 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 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 self.header_size = header_size | 346 self.header_size = header_size |
| 347 | 347 |
| 348 | 348 |
| 349 class CodeLogReader(object): | 349 class CodeLogReader(object): |
| 350 """V8 code event log reader.""" | 350 """V8 code event log reader.""" |
| 351 | 351 |
| 352 _CODE_INFO_RE = re.compile( | 352 _CODE_INFO_RE = re.compile( |
| 353 r"code-info,([^,]+),(\d+)") | 353 r"code-info,([^,]+),(\d+)") |
| 354 | 354 |
| 355 _CODE_CREATE_RE = re.compile( | 355 _CODE_CREATE_RE = re.compile( |
| 356 r"code-creation,([^,]+),(0x[a-f0-9]+),(\d+),\"([^\"]*)\"(?:,(\d+))?") | 356 r"code-creation,([^,]+),(0x[a-f0-9]+),(\d+),\"(.*)\"(?:,(\d+))?") |
| 357 | 357 |
| 358 _CODE_MOVE_RE = re.compile( | 358 _CODE_MOVE_RE = re.compile( |
| 359 r"code-move,(0x[a-f0-9]+),(0x[a-f0-9]+)") | 359 r"code-move,(0x[a-f0-9]+),(0x[a-f0-9]+)") |
| 360 | 360 |
| 361 _CODE_DELETE_RE = re.compile( | 361 _CODE_DELETE_RE = re.compile( |
| 362 r"code-delete,(0x[a-f0-9]+)") | 362 r"code-delete,(0x[a-f0-9]+)") |
| 363 | 363 |
| 364 _SNAPSHOT_POS_RE = re.compile( | 364 _SNAPSHOT_POS_RE = re.compile( |
| 365 r"snapshot-pos,(0x[a-f0-9]+),(\d+)") | 365 r"snapshot-pos,(0x[a-f0-9]+),(\d+)") |
| 366 | 366 |
| (...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 903 trace_reader = TraceReader(options.trace) | 903 trace_reader = TraceReader(options.trace) |
| 904 while True: | 904 while True: |
| 905 header, offset = trace_reader.ReadEventHeader() | 905 header, offset = trace_reader.ReadEventHeader() |
| 906 if not header: | 906 if not header: |
| 907 break | 907 break |
| 908 events += 1 | 908 events += 1 |
| 909 if header.type == PERF_RECORD_MMAP: | 909 if header.type == PERF_RECORD_MMAP: |
| 910 start = time.time() | 910 start = time.time() |
| 911 mmap_info = trace_reader.ReadMmap(header, offset) | 911 mmap_info = trace_reader.ReadMmap(header, offset) |
| 912 if mmap_info.filename == V8_GC_FAKE_MMAP: | 912 if mmap_info.filename == V8_GC_FAKE_MMAP: |
| 913 log_reader.ReadUpToGC() | 913 log_reader.ReadUpToGC(code_info) |
| 914 else: | 914 else: |
| 915 library_repo.Load(mmap_info, code_map, options) | 915 library_repo.Load(mmap_info, code_map, options) |
| 916 mmap_time += time.time() - start | 916 mmap_time += time.time() - start |
| 917 elif header.type == PERF_RECORD_SAMPLE: | 917 elif header.type == PERF_RECORD_SAMPLE: |
| 918 ticks += 1 | 918 ticks += 1 |
| 919 start = time.time() | 919 start = time.time() |
| 920 sample = trace_reader.ReadSample(header, offset) | 920 sample = trace_reader.ReadSample(header, offset) |
| 921 code = code_map.Find(sample.ip) | 921 code = code_map.Find(sample.ip) |
| 922 if code: | 922 if code: |
| 923 code.Tick(sample.ip) | 923 code.Tick(sample.ip) |
| (...skipping 22 matching lines...) Expand all Loading... |
| 946 print "%10d total ticks" % ticks | 946 print "%10d total ticks" % ticks |
| 947 print "%10d ticks not in symbols" % missed_ticks | 947 print "%10d ticks not in symbols" % missed_ticks |
| 948 print "%10d unaccounted ticks" % really_missed_ticks | 948 print "%10d unaccounted ticks" % really_missed_ticks |
| 949 print "%10d total symbols" % len([c for c in code_map.AllCode()]) | 949 print "%10d total symbols" % len([c for c in code_map.AllCode()]) |
| 950 print "%10d used symbols" % len([c for c in code_map.UsedCode()]) | 950 print "%10d used symbols" % len([c for c in code_map.UsedCode()]) |
| 951 print "%9.2fs library processing time" % mmap_time | 951 print "%9.2fs library processing time" % mmap_time |
| 952 print "%9.2fs tick processing time" % sample_time | 952 print "%9.2fs tick processing time" % sample_time |
| 953 | 953 |
| 954 log_reader.Dispose() | 954 log_reader.Dispose() |
| 955 trace_reader.Dispose() | 955 trace_reader.Dispose() |
| OLD | NEW |