#! /usr/bin/env python # ______________________________________________________________________ # # Filename: recostats # # Created: 26-AUG-2001, unknown # # ______________________________________________________________________ """Summarizes the results from running a D0Reco_x job. USAGE: recostats [-h] OPTIONS: -h, --help -- Print help text and exit. Execute this script in the directory containing the results of running D0Reco_x. """ # ______________________________________________________________________ import sys, os, glob, string # ______________________________________________________________________ __author__ = 'Harry Melanson, melanson@fnal.gov' __version__ = '01.00.00' __filename__ = 'recostats.py' __doc__ = __doc__ % vars() # ______________________________________________________________________ # ______________________________________________________________________ def process_command(): """Process the command.""" from scriptutil import getOptions optlist, args = getOptions('', [], __doc__) print '\nAnalyzing results... please wait.\n' exename = 'D0reco_x' # Get total CPU time used file = exename + '.out' command = 'grep -1 "Controller::/->" ' + file results = os.popen(command,'r').readlines() cputime = string.atof(string.split(results[-1],':')[-1]) # Get total memory used file = exename + '.log' command = 'cat ' + file + ' | grep --text "mem:"' results = os.popen(command,'r').readlines() memory = string.atof(string.split(results[-1])[-2]) # Get number of found tracks file = exename + '.out' command = 'grep "Number of tracks found" ' + file results = os.popen(command,'r').readlines() gtracks = string.atoi(string.split(results[0],'+')[1]) # Get average size of output file file = glob.glob('outputfile*')[0] command = 'chunkstats -n 10 ' + file results = os.popen(command,'r').readlines() chunksize = string.atof(string.split(results[-1])[-2]) print 'CPU time:', ('%.1f' % cputime), 'sec/event' print 'Memory:', ('%.1f' % memory), 'Mb' print 'File size:', chunksize, 'bytes' print 'Number of tracks:', gtracks # # Self-test if __name__ == '__main__': process_command() sys.exit(0)