Commit e45ccdcc authored by lizeb's avatar lizeb Committed by Commit bot

Speed up mergetraces.py.

list -> set, O(n^2) -> O(n).
Timing, without this patch (on a typical trace from a device):
real	1m49.774s
user	1m49.394s
sys	0m0.316s

With:
real	0m5.607s
user	0m5.482s
sys	0m0.120s

BUG=448054

Review URL: https://codereview.chromium.org/873003003

Cr-Commit-Position: refs/heads/master@{#313513}
parent b0e43f64
......@@ -101,7 +101,7 @@ def Convert (call_lines, startAddr, endAddr):
list of calls as tuples (sec, usec, pid:tid, callee)
"""
converted_calls = []
call_addresses = []
call_addresses = set()
for fields in call_lines:
secs = int (fields[0])
usecs = int (fields[1])
......@@ -111,7 +111,7 @@ def Convert (call_lines, startAddr, endAddr):
if (callee >= startAddr and callee < endAddr
and (not callee in call_addresses)):
converted_calls.append((secs, usecs, fields[2], (callee - startAddr)))
call_addresses.append(callee)
call_addresses.add(callee)
return converted_calls
def Timestamp(trace_entry):
......
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