android_prettifier_py
author Alon Zakai <azakai@mozilla.com>
Wed, 30 May 2012 16:31:59 -0700
changeset 585 694acee4d0b4
parent 438 ffc67cb6c4e4
permissions -rw-r--r--
work
diff --git a/tools/ipcprof/android_prettifier.py b/tools/ipcprof/android_prettifier.py
new file mode 100644
--- /dev/null
+++ b/tools/ipcprof/android_prettifier.py
@@ -0,0 +1,49 @@
+'''
+Useful tool to clean up android logging output.
+
+First, get the output by doing something like
+
+  ./adb logcat | grep Gecko &> a
+
+Then run this script on that:
+
+  python ~/Dev/mozilla-central/tools/ipcprof/android_prettifier.py a
+
+and it will generate e files for all processes.
+Then run the visualizer tool,
+
+  python ~/Dev/mozilla-central/tools/ipcprof/profiler.py e.PARENT# e.CHILD# 
+
+(You need to figure out the pid of the parent of child process. Note
+that several may be in your output, if the log you processed contained
+data from more than one run. Which is likely since logcat shows history for
+quite a ways back).
+
+3. Profit
+'''
+
+import os, sys
+
+filename = sys.argv[1]
+
+lines = open(filename, 'r').readlines()
+
+p_lines = {}
+
+for line in lines:
+  try:
+    pre, pid = line.split(')')[0].split('(')
+    pid = int(pid)
+  except:
+    continue
+  if 'Gecko' in pre:
+    try:
+      p_lines.setdefault(pid, []).append(line.split('): ')[1])
+    except:
+      pass
+
+for p in p_lines.keys():
+  f = open('e.' + str(p), 'w')
+  f.write(''.join(p_lines[p]))
+  f.close()
+