summaryrefslogtreecommitdiff
path: root/dump-build-times
diff options
context:
space:
mode:
authorJannis Pohlmann <jannis.pohlmann@codethink.co.uk>2012-04-12 11:25:05 +0100
committerJannis Pohlmann <jannis.pohlmann@codethink.co.uk>2012-04-12 11:25:05 +0100
commit412ead40e1e8671f84e28d15aad72c11a962c7a1 (patch)
tree9cd43e85059c943fce9c71ff9884a0162ca51ddc /dump-build-times
parentd7a7fc31242ba4ff88252bb0d6eca62ca327f8f0 (diff)
downloadmorph-412ead40e1e8671f84e28d15aad72c11a962c7a1.tar.gz
Dump build times of all passes in baserock-bootstrap.
This commit renames extract-build-times.py to dump-build-times and makes use of it after every pass in baserock-bootstrap. This will add the build times of all chunks to the bootstrap log.
Diffstat (limited to 'dump-build-times')
-rwxr-xr-xdump-build-times75
1 files changed, 75 insertions, 0 deletions
diff --git a/dump-build-times b/dump-build-times
new file mode 100755
index 00000000..5135ca04
--- /dev/null
+++ b/dump-build-times
@@ -0,0 +1,75 @@
+#!/usr/bin/env python
+#
+# Copyright (C) 2012 Codethink Limited
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+
+import cliapp
+import glob
+import json
+import os
+import re
+import StringIO
+
+
+class ExtractBuildTimes(cliapp.Application):
+
+ '''Extracts build times of chunks in a morph cache directory.
+
+ Given a morph cache directory as the first argument, this app finds all
+ cached chunks, loads their meta data and prints their build times.
+
+ '''
+
+ def process_args(self, args):
+ cachedir = args[0]
+
+ def chunk_hash(chunk):
+ short = re.split('\.', chunk)
+ return os.path.basename(short[-3])
+
+ def chunk_name(chunk):
+ short = re.split('\.', chunk)
+ return short[-1]
+
+ chunks = glob.glob(os.path.join(cachedir, '*.chunk.*'))
+ items = []
+
+ for chunk in chunks:
+ hash = chunk_hash(chunk)
+ metafile = os.path.join(cachedir, '%s.meta' % hash)
+ with open(metafile) as f:
+ data = f.read()
+ io = StringIO.StringIO(data)
+ metainfo = json.load(io)
+ time = metainfo['build-times']['overall-build']['delta']
+ minutes = float(time) / 60.0
+ items.append((chunk_name(chunk), minutes))
+
+ items = sorted(items, key=lambda x: x[1], reverse=True)
+ print '%s' % (43 * '-')
+ print 'Build times of cached chunks in'
+ print '%s' % cachedir
+ print '%s' % (43 * '-')
+ sum = 0.0
+ for name, time in items:
+ print '%30s: %6.1f mins' % (name, time)
+ sum += time
+ print '%s' % (43 * '-')
+ print '%30s: %6.1f mins' % ('total', sum)
+
+
+if __name__ == '__main__':
+ ExtractBuildTimes().run()