summaryrefslogtreecommitdiff
path: root/seivot
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2011-05-14 20:16:47 +0100
committerLars Wirzenius <liw@liw.fi>2011-05-14 20:16:47 +0100
commit6cc2307437b066b54126972f61a46b61fa341cb3 (patch)
tree623d88e337e867a9df8bfc412360e5319f5c5dfb /seivot
parent5f4906b6ce731fe18eca5567fd919202c5eac3e4 (diff)
downloadseivot-6cc2307437b066b54126972f61a46b61fa341cb3.tar.gz
Make seivot measure the size of the repository after each command.
Diffstat (limited to 'seivot')
-rwxr-xr-xseivot13
1 files changed, 13 insertions, 0 deletions
diff --git a/seivot b/seivot
index f619e92..7b06105 100755
--- a/seivot
+++ b/seivot
@@ -33,6 +33,7 @@ class Measurement(object):
self.real = fields[2]
self.maxrss = fields[3]
self.new_data = 0
+ self.repo_size_after = 0
def runcmd(argv, **kwargs):
@@ -262,6 +263,7 @@ class Report(object):
cp.set(section, '%s.%s' % (op, field),
'%.1f' % getattr(m, field))
cp.set(section, '%s.new-data' % op, m.new_data)
+ cp.set(section, '%s.repo-size-after' % op, m.repo_size_after)
cp.write(fp)
@@ -369,12 +371,23 @@ class Seivot(cliapp.Application):
drop_caches()
measurement = func(nth_gen, **kwargs)
measurement.new_data = new_data
+ measurement.repo_size_after = self.disk_usage(self.repo)
self.report.add_measurement(func.__name__, nth_gen, measurement)
def cleanup(self):
logging.info('Removing temporary directory %s' % self.tempdir)
shutil.rmtree(self.tempdir)
+ def disk_usage(self, pathname):
+ '''Simulate du(1). Return disk usage in bytes.'''
+ def getsize(filename):
+ return os.lstat(filename).st_blocks * 512
+ bytes = 0
+ for dirname, subdirs, basenames in os.walk(pathname):
+ bytes += getsize(dirname)
+ bytes += sum(getsize(os.path.join(dirname, x)) for x in basenames)
+ return bytes
+
if __name__ == '__main__':
Seivot().run()