summaryrefslogtreecommitdiffstats
path: root/toolkit/content/tests/fennec-tile-testapp/logread.py
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /toolkit/content/tests/fennec-tile-testapp/logread.py
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'toolkit/content/tests/fennec-tile-testapp/logread.py')
-rw-r--r--toolkit/content/tests/fennec-tile-testapp/logread.py104
1 files changed, 104 insertions, 0 deletions
diff --git a/toolkit/content/tests/fennec-tile-testapp/logread.py b/toolkit/content/tests/fennec-tile-testapp/logread.py
new file mode 100644
index 000000000..afa1fa524
--- /dev/null
+++ b/toolkit/content/tests/fennec-tile-testapp/logread.py
@@ -0,0 +1,104 @@
+#!/usr/bin/python
+import re, sys
+
+interesting_re = re.compile("(js_Execute|CallHook) ([^ ]+) ([^ ]+ )?([^ ]+ms)")
+class Entry:
+ def __init__(self, kind, depth, file, linenum, func, timetaken):
+ self.kind = kind
+ self.depth = depth
+ self.file = file
+ self.linenum = linenum
+ self.func = func
+ self.timetaken = timetaken
+ self.calls = 0
+ self.duration = 0
+
+ def __str__(self):
+ return " ".join(map(str,[self.kind, self.depth, self.file, self.linenum, self.func, self.timetaken]))
+
+ def id(self):
+ if self.kind == "js_Execute":
+ return self.file
+ else:
+ if self.file and self.linenum:
+ strout = "%s:%d" % (self.file, self.linenum)
+ if self.func:
+ strout = "%s %s" % (self.func, strout)
+ return strout
+ elif self.func:
+ return self.func
+ else:
+ print("No clue what my id is:"+self)
+
+ def call(self, timetaken):
+ self.calls += 1
+ self.duration += timetaken
+
+def parse_line(line):
+ m = interesting_re.search(line)
+ if not m:
+ return None
+
+ ms_index = line.find("ms")
+ depth = m.start() - ms_index - 3
+ kind = m.group(1)
+ func = None
+ file = None
+ linenum = None
+ if kind == "CallHook":
+ func = m.group(2)
+ file = m.group(3)
+ colpos = file.rfind(":")
+ (file,linenum) = file[:colpos], file[colpos+1:-1]
+ if linenum == "0":
+ linenum = None
+ else:
+ linenum = int(linenum)
+ offset = 1
+ else:
+ file = m.group(3)
+
+ timetaken = None
+ try:
+ timetaken = float(m.group(4)[:-2])
+ except:
+ return None
+ return Entry(kind, depth, file, linenum, func, timetaken)
+
+def compare(x,y):
+ diff = x[1].calls - y[1].calls
+ if diff == 0:
+ return int(x[1].duration - y[1].duration)
+ elif diff > 0:
+ return 1
+ elif diff < 0:
+ return -1
+
+def frequency(ls):
+ dict = {}
+ for item in ls:
+ id = item.id()
+ stat = None
+ if not id in dict:
+ stat = dict[id] = item
+ else:
+ stat = dict[id]
+ stat.call(item.timetaken)
+
+ ls = dict.items()
+ ls.sort(compare)
+ ls = filter(lambda (_,item): item.duration > 20, ls)
+# ls = filter(lambda (_,item): item.file and item.file.find("browser.js") != -1 and item.linenum <= 1223 and item.linenum >1067, ls)
+ for key, item in ls:
+ print(item.calls,key, str(item.duration)+"ms")
+
+def go():
+ file = sys.argv[1]
+
+ ls = filter(lambda x: x != None, map(parse_line, open(file).readlines()))
+
+ frequency(ls)
+ print ls[0]
+
+go()
+