2 print "run : --- Analyse production test pickle" 4 print "run : Importing modules" 11 from optparse
import OptionParser
12 parser = OptionParser()
13 parser.add_option(
"-p",
"--pickle", help=
"input pickle file", action=
"store", type=str, dest=
"pickle", default=
False)
14 parser.add_option(
"-o",
"--output", help=
"output file name", action=
"store", type=str, dest=
"output", default=
"analyse_pickle.root")
15 parser.add_option(
"-v",
"--verbose", help=
"turn on verbose mode", action=
"store_true", dest=
"verbose", default=
False)
16 (options, args) = parser.parse_args()
18 print "run : --- Options" 19 print "run : pickle: ",options.pickle
20 print "run : output: ",options.output
21 print "run : verbose mode: ",options.verbose
22 assert (options.pickle),
"No file provided to unpickle, specify one with -p MYFILE" 24 print "run : Opening pickle file %s"%options.pickle
25 chain = cPickle.load(
open(options.pickle,
"rb"))
27 attributes = [
"memory",
43 SLICE_IN_SECONDS = 0.1
44 SLICE_IN_MINUTES = SLICE_IN_SECONDS/60.
45 for tier
in chain.tiers:
47 if (tier.metric.run ==
False):
continue 48 histograms[tier.short_name] = {}
56 events[tier.short_name] = art_events.events
57 queries[tier.short_name] = art_events.queries
58 parsing[tier.short_name] = art_events.parsing
59 for attribute
in attributes:
60 values = getattr(metric,attribute)
61 times = metric.sample_times
63 hist = ROOT.TGraph(len(times))
64 hist.SetName(
"%s_%s"%(tier.short_name,attribute))
65 hist.SetTitle(
"%s_%s;time [s];%s"%(tier.short_name,attribute,attribute))
67 for i, time
in enumerate(times):
68 hist.SetPoint(i,time,values[i])
70 histograms[tier.short_name][attribute] = hist
73 ROOT.gROOT.SetStyle(
"novaStyle")
74 ROOT.gROOT.ForceStyle()
75 canvas = ROOT.TCanvas(
"canvas",
"variable",700,600)
77 ps =
"AnalysePickle-Histograms.pdf" 79 for tier
in chain.tiers:
81 if (tier.metric.run ==
False):
continue 82 for attribute
in attributes:
84 this_hist = histograms[tier.short_name][attribute]
86 this_events = events[tier.short_name]
87 this_queries = queries[tier.short_name]
88 this_parsing = parsing[tier.short_name]
91 for event
in this_events.keys():
92 t_0 = this_events[event]
93 line = ROOT.TLine(t_0,
94 this_hist.GetHistogram().GetMinimum(),
97 line.SetLineColor(ROOT.kRed)
101 for query
in this_queries.keys():
102 t_0 = this_queries[query]
103 line = ROOT.TLine(t_0,
104 this_hist.GetHistogram().GetMinimum(),
107 line.SetLineColor(ROOT.kMagenta+3)
111 for parse
in this_parsing.keys():
112 t_0 = this_parsing[parse]
113 line = ROOT.TLine(t_0,
114 this_hist.GetHistogram().GetMinimum(),
117 line.SetLineColor(ROOT.kCyan+1)
127 print "run : Saved histograms to: %s"%ps
130 print "run : Saving output to %s"%options.output
131 root_file = ROOT.TFile(options.output,
"RECREATE")
132 for tier
in chain.tiers:
133 if (tier.metric.run ==
False):
continue 134 for attribute
in attributes:
135 histograms[tier.short_name][attribute].
Write()
138 print "run : --- Done\n" procfile open("FD_BRL_v0.txt")
def parseLines(lines, verbose=False)
Parse output file.