From dd96803d10bfde07f970755614948b80200843b6 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Sat, 31 Mar 2012 21:05:34 -0700 Subject: add js bloatscan tool --- tools/scan_js.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 tools/scan_js.py 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]))) + -- cgit v1.2.3-18-g5258