CMS 3D CMS Logo

cmsBenchmarkReader.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 import pickle, os, sys
3 
4 ####################
5 #
6 # Parses name of datafile from the arguments
7 #
8 def optionParse():
9  parser = opt.OptionParser()
10  parser.add_option_group(devel)
11  (options, args) = parser.parse_args()
12 
13  if not len(args) == 1:
14  parser.error("you must only pass one file as an argument")
15  sys.exit()
16 
17  datafile = os.path.abspath(args[0])
18  if not os.path.isfile(datafile):
19  parser.error("%s file does not exist" % datafile)
20  sys.exit()
21 
22  return datafile
23 
24 ########################################
25 # (this could be cleaned up a little bit)
26 # Format of the data file should be:
27 #
28 # [ host_tuple ] # list of host data
29 #
30 # host_tuple = ( hostname, [ command_results ]) # hostname and list of results (one for each job specification: each run)
31 #
32 # command_results = {cpu_id: data_output} # contains a dictionary, one set of data for each cpu
33 #
34 # For example:
35 # returned data = [ cmd_output1, cmd_output2 ... ]
36 # cmd_output1 = { cpuid1 : cpu_output1, cpuid2 : cpu_output2 ... } # cpuid is "None" if there was only one cpu used
37 # cpu_output1 = { candle1 : profset_output1, candle2 : profset_output2 ... }
38 # profset_output1 = { profset1 : profile_output1, ... }
39 # profile_output1 = { profiletype1: step_output1, ... }
40 # step_output1 = { step1: list_of_cpu_times, ... }
41 # list_of_cpu_times = [ (evt_num1, secs1), ... ]
42 #
43 def printBenchmarkData(afile):
44  ph = open(afile,"rb")
45  list = pickle.load(ph)
46  ph.close()
47  for host, data in list:
48  try:
49  for options, cpudata in data:
50  for cpukey in cpudata:
51  cpustr = ""
52  if cpukey == "None":
53  cpustr = "cpu: " + str(options["cpus"][0])
54  else:
55  cpustr = "cpu: " + str(cpukey)
56  candledata = cpudata[cpukey]
57  for candlekey in candledata:
58  profsetdata = candledata[candlekey]
59  for profsetkey in profsetdata:
60  profiledata = profsetdata[profsetkey]
61  for profilekey in profiledata:
62  stepdata = profiledata[profilekey]
63  for stepkey in stepdata:
64  print "Host: " + str(host)
65  print "Options: " + str(options)
66  print cpustr
67  print "candle: " + str(candlekey)
68  print "profsetdata: " + str(profsetkey)
69  print "profiler: " + str(profilekey)
70  print "step: " + str(stepkey)
71  for evtdat in stepdata[stepkey]:
72  print evtdat
73  except TypeError as detail:
74  print "Data: does not exist for this machine, the server failed to return a valid data structure"
75  print detail
76 
77 
78 if __name__ == "__main__":
79  datafile = optionParse()
80  printBenchmarkData(datafile)
def optionParse()
Parses name of datafile from the arguments.
def printBenchmarkData(afile)
(this could be cleaned up a little bit) Format of the data file should be: