aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2012-03-31 21:05:34 -0700
committerAlon Zakai <alonzakai@gmail.com>2012-03-31 21:05:34 -0700
commitdd96803d10bfde07f970755614948b80200843b6 (patch)
tree3ec8630913a1e036d0e70dcf40f91848a226d906
parentaa601bc9991f1e5a029fea9d21b1ade6cd5fa812 (diff)
add js bloatscan tool
-rw-r--r--tools/scan_js.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/tools/scan_js.py b/tools/scan_js.py
new file mode 100644
index 00000000..eeff7c7c
--- /dev/null
+++ b/tools/scan_js.py
@@ -0,0 +1,20 @@
+'''
+Finds why a .js file is large by printing functions by size
+'''
+
+import os, sys
+
+funcs = []
+i = 0
+inside = None
+for line in open(sys.argv[1]):
+ i += 1
+ if line.startswith('function _'):
+ inside = line.replace('function ', '').replace('\n', '')
+ start = i
+ elif inside and line.startswith('}'):
+ funcs.append((inside, i-start))
+ inside = None
+
+print '\n'.join(map(lambda func: str(func[1]) + ':' + func[0], sorted(funcs, key=lambda func: -func[1])))
+