#
# Copyright (C) 2001 Andrew T. Csillag <drew_csillag@geocities.com>
#
# You may distribute under the terms of either the GNU General
# Public License or the SkunkWeb License, as specified in the
# README file.
#
#!/usr/local/bin/python
#
# Take the results generated by 'test_read_write' thing and collate into
# HTML tables, for easy side-by-side comparrison
#
# Roman, Starmedia, 2000
import sys, cPickle, pprint
_outfile = 'results.html'
if len(sys.argv) == 1:
print 'Usage: %s <result_file_1> <result_file_2> ...'
print 'Output will be saved to file "%s"' % _outfile
sys.exit(1)
_res = []
for f in sys.argv[1:]:
try:
data = cPickle.load ( open ( f, 'r' ) )
except IOError:
print 'Error: cannot read file %s' % f
sys.exit(1)
except PickleError:
print 'Error: file %s doesn\'t seem to contain results data'
sys.exit(1)
_res.append ( data )
print 'File %s: data for %s' % ( f, data[0] )
# Sort the results
_res.sort ( lambda x, y: cmp ( x[1], y[1] ))
out = open ( _outfile, 'w' )
def gen_headers ( out, res ):
"""
Generate the headers
"""
out.write ( ' <tr>\n' )
out.write ( ' <th>File (kb)</th>\n' )
out.write ( ' <th>Operation</th>\n' )
for r in res:
out.write ( ' <th align=center>%s</th>\n' % r[0])
out.write ( ' </tr>\n\n' )
_fields = ( 'write', 'rename', 'write_rename', 'read', 'stat' )
def gen_size_data ( out, size, res ):
"""
Generate data for a single size
"""
out.write ( ' <tr>\n' )
out.write ( ' <td align=center rowspan=%d><b>%.1f</b></tr>\n' %
(len(_fields) + 1, float(size) / 1024 ))
for f in _fields:
out.write ( ' <td>%s</td>\n' % f)
for r in res:
out.write ( ' <td align=right>%.6fs</td>\n' % r[size][f])
out.write ( ' </tr>\n' )
out.write ( ' <tr>\n' )
# Do the totals
out.write ( ' <td><b><i>%s</b></i></td>\n' % 'Total')
for r in res:
out.write ( ' <td align=right><b>%.3fs<b></td>\n' % r[size]['total'])
out.write ( ' </tr>\n\n' )
#
# Ok, now - begin generating the HTML table
#
out.write ( '<html>\n' )
out.write ( '<title>Disk benchmark results</title>\n' )
out.write ( '<body color="blue" bgcolor="white">\n' )
out.write ( '<table border=3 width=100%>\n' )
# Generate the header data
gen_headers ( out, _res )
# Get the list of sizes
datas = map ( lambda x : x[2], _res )
sizes = datas[0].keys() # Assume all data is homogeneous
sizes.sort()
for s in sizes:
gen_size_data ( out, s, datas )
# Close the table
out.write ( ' <tr>\n' )
out.write ( ' <td colspan=2><b>Total time:</b></td>\n' )
for r in _res:
out.write ( ' <td align=right><b>%.4f sec</b></td>\n' % r[1] )
out.write ( ' </tr>\n' )
# Close the table
out.write ( '</table>\n</html>\n' )
out.close()
# All done!
|