Bug 918581 - Extend merge-profile.py to support secondary threads. r=vlad, a=lsblakk
authorBenoit Girard <b56girard@gmail.com>
Thu, 19 Sep 2013 23:24:07 -0400
changeset 160651 65d553f4186cf68b942b84caa61c618336e804cf
parent 160650 331b31231aa1dfc4f416d20a71723448f287678d
child 160652 ffd5dbcf417707aab29c7238e23e8310aa409279
push id2961
push userlsblakk@mozilla.com
push dateMon, 28 Oct 2013 21:59:28 +0000
treeherdermozilla-beta@73ef4f13486f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvlad, lsblakk
bugs918581
milestone26.0a2
Bug 918581 - Extend merge-profile.py to support secondary threads. r=vlad, a=lsblakk
tools/profiler/merge-profiles.py
--- a/tools/profiler/merge-profiles.py
+++ b/tools/profiler/merge-profiles.py
@@ -31,37 +31,37 @@ def MergeProfiles(files):
         if meta is None:
             meta = fileData['profileJSON']['meta'].copy()
             libs = fileData['profileJSON']['libs']
             minStartTime = meta['startTime']
         else:
             minStartTime = min(minStartTime, fileData['profileJSON']['meta']['startTime'])
             meta['startTime'] = minStartTime
 
-        thread = fileData['profileJSON']['threads'][0]
-        thread['name'] = pname + " (" + pid + ")"
-        threads.append(thread)
+        for thread in fileData['profileJSON']['threads']:
+            thread['name'] = thread['name'] + " (" + pname + ":" + pid + ")"
+            threads.append(thread)
 
-        # Note that pid + sym, pid + location could be ambigious
-        # if we had pid=11 sym=1 && pid=1 sym=11. To avoid this we format
-        # pidStr with leading zeros.
-        pidStr = "%05d" % (int(pid))
+            # Note that pid + sym, pid + location could be ambigious
+            # if we had pid=11 sym=1 && pid=1 sym=11. To avoid this we format
+            # pidStr with leading zeros.
+            pidStr = "%05d" % (int(pid))
 
-        thread['startTime'] = fileData['profileJSON']['meta']['startTime']
-        samples = thread['samples']
-        for sample in thread['samples']:
-            for frame in sample['frames']:
-                if "location" in frame and frame['location'][0:2] == '0x':
-                    frame['location'] = pidStr + frame['location']
+            thread['startTime'] = fileData['profileJSON']['meta']['startTime']
+            samples = thread['samples']
+            for sample in thread['samples']:
+                for frame in sample['frames']:
+                    if "location" in frame and frame['location'][0:2] == '0x':
+                        frame['location'] = pidStr + frame['location']
 
         filesyms = fileData['symbolicationTable']
         for sym in filesyms.keys():
             symTable[pidStr + sym] = filesyms[sym]
 
-    # For each process, make the time offsets line up based on the
+    # For each thread, make the time offsets line up based on the
     # earliest start
     for thread in threads:
         delta = thread['startTime'] - minStartTime
         for sample in thread['samples']:
             if "time" in sample:
                 sample['time'] += delta
 
     result = dict()