diff options
author | Lars Wirzenius <liw@liw.fi> | 2011-04-19 22:48:19 +0100 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2011-04-19 22:48:19 +0100 |
commit | a92fea7f35707a93d3a0c75c4e9a7aeff88ef9d1 (patch) | |
tree | f7794fcd54d1a9d9284d290a16f2f4c43dbc99e8 /seivots-to-csv | |
parent | 0cde89a887e4c6b406f32c2312e0a04307dbf1e8 (diff) | |
download | seivot-a92fea7f35707a93d3a0c75c4e9a7aeff88ef9d1.tar.gz |
Add program to create summary CSVs from a set of seivots.
Diffstat (limited to 'seivots-to-csv')
-rwxr-xr-x | seivots-to-csv | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/seivots-to-csv b/seivots-to-csv new file mode 100755 index 0000000..552b21f --- /dev/null +++ b/seivots-to-csv @@ -0,0 +1,79 @@ +#!/usr/bin/python +# Copyright 2011 Lars Wirzenius +# +# 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, either version 3 of the License, or +# (at your option) any later version. +# +# 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, see <http://www.gnu.org/licenses/>. + + +import cliapp +import ConfigParser +import csv + + +class SeivotToCsv(cliapp.Application): + + def process_args(self, args): + seivots = [] + for filename in args: + seivots.append(self.read_seivot(filename)) + + def getkey(s): + return (s.get('meta', 'revision'), + s.get('meta', 'larch-revision')) + seivots.sort(key=getkey) + + for op in ['backup', 'restore', 'list_files', 'forget']: + f = open('%s.csv' % op, 'w') + writer = csv.writer(f) + writer.writerow(['obnam', 'larch', 'gen0 time (s)', + 'gen0 RAM (MiB)', 'slowest inc (s)', + 'largest RAM inc (MiB)']) + for seivot in seivots: + row = self.get_row_data(op, seivot) + writer.writerow(row) + f.close() + + def read_seivot(self, filename): + cp = ConfigParser.ConfigParser() + cp.read([filename]) + return cp + + def get_row_data(self, op, seivot): + row = ['r%s' % seivot.get('meta', 'revision'), + 'r%s' % seivot.get('meta', 'larch-revision'), + seivot.getfloat('0', '%s.real' % op), + self.bytesize(seivot.getfloat('0', '%s.maxrss' % op)), + self.find_slowest_incremental(op, seivot), + self.find_largest_incremental(op, seivot)] + return row + + def values(self, op, suffix, seivot): + for section in seivot.sections(): + if section not in ['meta', '0']: + yield seivot.getfloat(section, '%s.%s' % (op, suffix)) + + def find_slowest_incremental(self, op, seivot): + v = self.values(op, 'real', seivot) + return min(list(v) or [0.0]) + + def find_largest_incremental(self, op, seivot): + v = self.values(op, 'maxrss', seivot) + return self.bytesize(min(list(v) or [0.0])) + + def bytesize(self, kilobytes): + return '%.1f' % (float(kilobytes) / 1024) + + +if __name__ == '__main__': + SeivotToCsv().run() + |