diff options
| author | Jim Ingham <jingham@apple.com> | 2012-03-01 18:57:51 +0000 |
|---|---|---|
| committer | Jim Ingham <jingham@apple.com> | 2012-03-01 18:57:51 +0000 |
| commit | d95752f24031349a227d1c80864a5f934d29f761 (patch) | |
| tree | 6a047f6d59463b13f80bd43cc477d6b5eb249029 /lldb/examples/python | |
| parent | 1d03a3b6b174e46ce6b4730f9a309cd7f7c4d6a6 (diff) | |
| download | bcm5719-llvm-d95752f24031349a227d1c80864a5f934d29f761.tar.gz bcm5719-llvm-d95752f24031349a227d1c80864a5f934d29f761.zip | |
Add an option to sort by packet count (rather than time). Also print the count,
and to print the total count & time in the header.
llvm-svn: 151823
Diffstat (limited to 'lldb/examples/python')
| -rwxr-xr-x | lldb/examples/python/gdbremote.py | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/lldb/examples/python/gdbremote.py b/lldb/examples/python/gdbremote.py index 59d7eb8082e..73ef85349cb 100755 --- a/lldb/examples/python/gdbremote.py +++ b/lldb/examples/python/gdbremote.py @@ -72,6 +72,7 @@ def stop_gdb_log(debugger, command, result, dict): parser = optparse.OptionParser(description=description, prog='stop_gdb_log',usage=usage) parser.add_option('-v', '--verbose', action='store_true', dest='verbose', help='display verbose debug info', default=False) parser.add_option('-q', '--quiet', action='store_true', dest='quiet', help='display verbose debug info', default=False) + parser.add_option('-c', '--sort-by-count', action='store_true', dest='sort_count', help='display verbose debug info', default=False) try: (options, args) = parser.parse_args(command_args) except: @@ -108,6 +109,7 @@ def parse_gdb_log_file(file, options): packet_send_time = 0.0 packet_name = None packet_total_times = {} + packet_count = {} file = open(file) lines = file.read().splitlines() for line in lines: @@ -131,8 +133,10 @@ def parse_gdb_log_file(file, options): elif line.find('read packet: $') >= 0 and packet_name: if packet_name in packet_total_times: packet_total_times[packet_name] += delta + packet_count[packet_name] += 1 else: packet_total_times[packet_name] = delta + packet_count[packet_name] = 1 packet_name = None if not options or not options.quiet: @@ -142,25 +146,34 @@ def parse_gdb_log_file(file, options): print line if packet_total_times: total_packet_time = 0.0 + total_packet_count = 0 for key, vvv in packet_total_times.items(): # print ' key = (%s) "%s"' % (type(key), key) # print 'value = (%s) %s' % (type(vvv), vvv) # if type(vvv) == 'float': total_packet_time += vvv - print '#--------------------------------------------' + for key, vvv in packet_count.items(): + total_packet_count += vvv + + print '#---------------------------------------------------' print '# Packet timing summary:' - print '#--------------------------------------------' - print '# Packet Time (sec) Percent' - print '#------------------------- ---------- -------' - res = sorted(packet_total_times, key=packet_total_times.__getitem__, reverse=True) + print '# Totals: time - %6f count %6d' % (total_packet_time, total_packet_count) + print '#---------------------------------------------------' + print '# Packet Time (sec) Percent Count ' + print '#------------------------- ---------- ------- ------' + if options and options.sort_count: + res = sorted(packet_count, key=packet_count.__getitem__, reverse=True) + else: + res = sorted(packet_total_times, key=packet_total_times.__getitem__, reverse=True) + if last_time > 0.0: for item in res: packet_total_time = packet_total_times[item] packet_percent = (packet_total_time / total_packet_time)*100.0 if packet_percent >= 10.0: - print " %24s %.6f %.2f%%" % (item, packet_total_time, packet_percent) + print " %24s %.6f %.2f%% %6d" % (item, packet_total_time, packet_percent, packet_count[item]) else: - print " %24s %.6f %.2f%%" % (item, packet_total_time, packet_percent) + print " %24s %.6f %.2f%% %6d" % (item, packet_total_time, packet_percent, packet_count[item]) |

