Commit 39e13733 authored by Brendan Gregg's avatar Brendan Gregg

improve code by utilizing trace_readline_fields()

parent ef2452db
...@@ -33,16 +33,10 @@ except: ...@@ -33,16 +33,10 @@ except:
# format output # format output
while 1: while 1:
try: (task, pid, cpu, flags, ts, msg) = b.trace_readline_fields()
line = trace.readline().rstrip() (bytes_s, bflags_s, us_s) = msg.split()
except KeyboardInterrupt:
pass; exit() if int(bflags_s, 16) & REQ_WRITE:
prolog, time_s, colon, bytes_s, flags_s, us_s = \
line.rsplit(" ", 5)
time_s = time_s[:-1] # strip trailing ":"
flags = int(flags_s, 16)
if flags & REQ_WRITE:
type_s = "W" type_s = "W"
elif bytes_s == "0": # see blk_fill_rwbs() for logic elif bytes_s == "0": # see blk_fill_rwbs() for logic
type_s = "M" type_s = "M"
...@@ -50,4 +44,4 @@ while 1: ...@@ -50,4 +44,4 @@ while 1:
type_s = "R" type_s = "R"
ms = float(int(us_s, 10)) / 1000 ms = float(int(us_s, 10)) / 1000
print("%-18s %-2s %-7s %8.2f" % (time_s, type_s, bytes_s, ms)) print("%-18.9f %-2s %-7s %8.2f" % (ts, type_s, bytes_s, ms))
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment