class Summary:
"""Stores and prints results of building different things"""
def __init__(self):
self._table = []
def store(self, project, compiler, elapsed_times):
"""
elapsed_times is a sequence of elapsed times to build the project.
A sequence because we can build projects repeatedly.
"""
self._table.append((project.name, compiler.name, elapsed_times))
def print_raw(self):
from pprint import pprint
pprint(self._table)
def print_table(self):
import time, os, sys
import statistics
"""Print out in a nice tabular form"""
print """
========================
distcc benchmark results
========================
"""
print "Date: ", time.ctime()
print "DISTCC_HOSTS: %s" % `os.getenv('DISTCC_HOSTS')`
sys.stdout.flush()
os.system("uname -snrvpo")
print "%-20s %-30s %8s %8s" % ('project', 'compiler', 'time', 's.d.')
for row in self._table:
print "%-20s %-30s " % row[:2],
times = row[2]
if times == 'FAIL':
print '%9s' % 'FAIL'
else:
mean = statistics.mean(times)
sd = statistics.std(times)
print "%8.4fs" % mean,
if sd is None:
print "%9s" % "n/a"
else:
print "%8.4fs" % sd