summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYabin Cui <yabinc@google.com>2017-11-10 14:19:09 -0800
committerYabin Cui <yabinc@google.com>2017-11-10 14:19:09 -0800
commit439e1e56813832ab7257a18e47032314e6afe38c (patch)
tree4725485fee82a5e32ea13cca1a8580a627f8d9f3
parent3ae4af480e91f48f8e8dad2ee38e151d043ed1d8 (diff)
downloadextras-439e1e56813832ab7257a18e47032314e6afe38c.tar.gz
inferno: sort threads by the event count in a thread.
Sometimes a thread having only several samples comes first, and looks like it is the most important thread. So sort threads by the event count to make really important threads shows first. Bug: none. Test: run inferno.sh. Change-Id: Ic8406fb19d72d2599c78589d9f4876875dad00e8
-rw-r--r--simpleperf/scripts/inferno/inferno.py11
1 files changed, 2 insertions, 9 deletions
diff --git a/simpleperf/scripts/inferno/inferno.py b/simpleperf/scripts/inferno/inferno.py
index 834bbbbb..ad64f9af 100644
--- a/simpleperf/scripts/inferno/inferno.py
+++ b/simpleperf/scripts/inferno/inferno.py
@@ -186,15 +186,8 @@ def output_report(process, args):
if not args.embedded_flamegraph:
f.write("<script>document.addEventListener('DOMContentLoaded', flamegraphInit);</script>")
- # Output tid == pid Thread first.
- main_thread = [x for x in process.threads.values() if x.tid == process.pid]
- for thread in main_thread:
- f.write("<br/><br/><b>Main Thread %d (%s) (%d samples):</b><br/>\n\n\n\n" % (
- thread.tid, thread.name, thread.num_samples))
- renderSVG(thread.flamegraph, f, args.color)
-
- other_threads = [x for x in process.threads.values() if x.tid != process.pid]
- for thread in other_threads:
+ # Sort threads by the event count in a thread.
+ for thread in sorted(process.threads.values(), key=lambda x: x.event_count, reverse=True):
f.write("<br/><br/><b>Thread %d (%s) (%d samples):</b><br/>\n\n\n\n" % (
thread.tid, thread.name, thread.num_samples))
renderSVG(thread.flamegraph, f, args.color)