#!/usr/bin/python import ConfigParser import glob import os import re import sys import urllib def humantime(secs): units = ( ('h', 60*60), ('min', 60), ('s', 1), ) result = '' for unit, factor in units: if secs >= factor: result += '%d%s' % (int(secs / factor), unit) secs %= factor return result def humansize(bytes): units = ( ('MiB', 1024**2), ('KiB', 1024**1), ('B', 1024**0), ) for unit, factor in units: if bytes >= factor: return '%.1f %s' % (float(bytes / factor), unit) return '0 B' def humanspeed(bytes_per_second): bits_per_second = 8 * bytes_per_second factor = 1000**2 unit = 'Mbit/s' return '%.1f %s' % (float(bits_per_second / factor), unit) class Report(object): def __init__(self): self.seivots = [] def load_seivot(self, filename): cp = ConfigParser.RawConfigParser() cp.read(filename) cp.filename = filename self.seivots.append(cp) def parse_revision(self, seivot): revstr = seivot.get('meta', 'revision') if ' and ' in revstr: obnam, larch = revstr.split(' and ') return int(obnam), int(larch) else: return int(revstr), 0 def sort(self): def getkey(seivot): return seivot.get('meta', 'revision') pairs = [(getkey(seivot), seivot) for seivot in self.seivots] pairs.sort() self.seivots = [seivot for key, seivot in pairs] def groups(self, seivots): def getkey(seivot): return (seivot.get('meta', 'start-size'), seivot.get('meta', 'inc-size')) keys = sorted(list(set(getkey(s) for s in seivots))) for key in keys: yield [s for s in seivots if getkey(s) == key] def report(self, f): self.sort() self.preamble(f) for group in self.groups(self.seivots): self.report_group(f, group) self.footer(f) def preamble(self, f): f.write(''' [[!meta title="Obnam benchmark archive"]] Obnam+larch benchmark archive ==== This page lists results of benchmark runs of [[Obnam]], done by Lars Wirzenius. See [[the obnam benchmark page|benchmarkspec]] for information on how the benchmark is set up, and [[the result listing|benchmarks]] for individual result. This page has summarizes results of each benchmark run, so they can be compared. ''') def footer(self, f): pass def report_group(self, f, group): size = group[0].getint('meta', 'start-size') inc = group[0].getint('meta', 'inc-size') f.write('Size %s, increment %s\n----\n' % (humansize(size), humansize(inc))) f.write('''
obnam | larch | gen0 | slowest inc |
---|---|---|---|
%s | \n' % obnam) f.write('%s | \n' % larch) f.write('%s | \n' % humanspeed(gen0)) f.write('%s | \n' % humanspeed(slowest_inc)) f.write('