CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_9_patch3/src/Validation/Performance/scripts/cmsBenchmarkReader.py

Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 import pickle, os, sys
00003 
00004 ####################
00005 #
00006 # Parses name of datafile from the arguments
00007 #
00008 def optionParse():
00009     parser = opt.OptionParser()
00010     parser.add_option_group(devel)
00011     (options, args) = parser.parse_args()
00012 
00013     if not len(args) == 1:
00014         parser.error("you must only pass one file as an argument")
00015         sys.exit()
00016 
00017     datafile = os.path.abspath(args[0])
00018     if not os.path.isfile(datafile):
00019         parser.error("%s file does not exist" % datafile)
00020         sys.exit()
00021         
00022     return datafile
00023 
00024 ########################################
00025 # (this could be cleaned up a little bit)
00026 # Format of the data file should be:
00027 # 
00028 #  [ host_tuple ]    # list of host data
00029 #
00030 #  host_tuple = ( hostname, [ command_results ]) # hostname and list of results (one for each job specification: each run)
00031 #
00032 #  command_results = {cpu_id: data_output}       # contains a dictionary, one set of data for each cpu
00033 #
00034 # For example:
00035 # returned data     = [ cmd_output1, cmd_output2 ... ]
00036 # cmd_output1       = { cpuid1 : cpu_output1, cpuid2 : cpu_output2 ... }     # cpuid is "None" if there was only one cpu used
00037 # cpu_output1       = { candle1  : profset_output1, candle2 : profset_output2 ... }
00038 # profset_output1   = { profset1 : profile_output1, ... }
00039 # profile_output1   = { profiletype1: step_output1, ... }
00040 # step_output1      = { step1: list_of_cpu_times, ... }
00041 # list_of_cpu_times = [ (evt_num1, secs1), ... ]
00042 #
00043 def printBenchmarkData(afile):
00044     ph = open(afile,"rb")
00045     list = pickle.load(ph)
00046     ph.close()
00047     for host, data in list:
00048         try:
00049             for options, cpudata in data:
00050                 for cpukey in cpudata:
00051                     cpustr = ""
00052                     if cpukey == "None":
00053                         cpustr = "cpu: " + str(options["cpus"][0])
00054                     else:
00055                         cpustr = "cpu: " + str(cpukey)
00056                     candledata = cpudata[cpukey] 
00057                     for candlekey in candledata:
00058                         profsetdata = candledata[candlekey] 
00059                         for profsetkey in profsetdata:
00060                             profiledata = profsetdata[profsetkey]
00061                             for profilekey in profiledata:
00062                                 stepdata = profiledata[profilekey] 
00063                                 for stepkey in stepdata:
00064                                     print "Host: " + str(host)
00065                                     print "Options: " + str(options)
00066                                     print cpustr
00067                                     print "candle: " + str(candlekey)
00068                                     print "profsetdata: " + str(profsetkey)                                
00069                                     print "profiler: " + str(profilekey)                                
00070                                     print "step: " + str(stepkey)
00071                                     for evtdat in stepdata[stepkey]:
00072                                         print evtdat
00073         except TypeError, detail:
00074             print "Data: does not exist for this machine, the server failed to return a valid data structure"
00075             print detail
00076 
00077 
00078 if __name__ == "__main__":
00079     datafile = optionParse()
00080     printBenchmarkData(datafile)