CMS 3D CMS Logo

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