2 from __future__
import print_function
3 from builtins
import range
4 from itertools
import groupby
5 from operator
import attrgetter,itemgetter
8 from collections
import defaultdict
12 To Use: Add the Tracer Service to the cmsRun job use something like this 15 process.add_(cms.Service("Tracer", fileName = cms.untracked.string("tracer.log"))) 17 After running the job, execute this script and pass the name of the 18 Tracer log file to the script. 20 This script will output a more human readable form of the data in the Tracer log file.''' 48 kMicroToSec = 0.000001
50 kSourceFindEvent =
"sourceFindEvent" 51 kSourceDelayedRead =
"sourceDelayedRead" 53 kLargestLumiNumber = 4294967295
60 writeProcessBlock = -10
74 accessInputProcessBlock = 8
81 getNextTransition = 15
94 transitionToNames_ = {
95 Phase.startTracing:
'start tracing',
96 Phase.construction:
'construction',
97 Phase.destruction:
'destruction',
98 Phase.beginJob:
'begin job',
99 Phase.endJob:
'end job',
100 Phase.beginStream:
'begin stream',
101 Phase.endStream:
'end stream',
102 Phase.beginProcessBlock:
'begin process block',
103 Phase.endProcessBlock:
'end process block',
104 Phase.accessInputProcessBlock:
'access input process block',
105 Phase.writeProcessBlock:
'write process block',
106 Phase.globalBeginRun:
'global begin run',
107 Phase.globalEndRun:
'global end run',
108 Phase.globalWriteRun:
'global write run',
109 Phase.streamBeginRun:
'stream begin run',
110 Phase.streamEndRun:
'stream end run',
111 Phase.globalBeginLumi:
'global begin lumi',
112 Phase.globalEndLumi:
'global end lumi',
113 Phase.globalWriteLumi:
'global write lumi',
114 Phase.streamBeginLumi:
'stream begin lumi',
115 Phase.streamEndLumi:
'stream end lumi',
116 Phase.esSyncEnqueue:
'EventSetup synchronization',
117 Phase.esSync:
'EventSetup synchronization',
118 Phase.Event:
'event',
119 Phase.clearEvent:
'clear event',
120 Phase.getNextTransition:
'get next transition' 124 return transitionToNames_[transition]
126 transitionToIndent_ = {
127 Phase.startTracing: 0,
128 Phase.construction: 0,
129 Phase.destruction: 0,
132 Phase.beginStream: 0,
134 Phase.beginProcessBlock: 1,
135 Phase.endProcessBlock: 1,
136 Phase.accessInputProcessBlock: 1,
137 Phase.writeProcessBlock: 1,
138 Phase.globalBeginRun: 1,
139 Phase.globalEndRun: 1,
140 Phase.globalWriteRun: 1,
141 Phase.streamBeginRun: 1,
142 Phase.streamEndRun: 1,
143 Phase.globalBeginLumi: 2,
144 Phase.globalEndLumi: 2,
145 Phase.globalWriteLumi: 2,
146 Phase.streamBeginLumi: 2,
147 Phase.streamEndLumi: 2,
150 Phase.esSyncEnqueue: 1,
152 Phase.getNextTransition: 1
155 return transitionToIndent_[transition]
157 globalTransitions_ = {
163 Phase.beginProcessBlock,
164 Phase.endProcessBlock,
165 Phase.accessInputProcessBlock,
166 Phase.writeProcessBlock,
167 Phase.globalBeginRun,
169 Phase.globalWriteRun,
170 Phase.globalBeginLumi,
172 Phase.globalWriteLumi,
175 Phase.getNextTransition
178 return transition
in globalTransitions_;
182 return f
'{time:>11} '+
"++"*indentLevel
196 return f
'run={self.sync[0]}' 198 return f
'run={self.sync[0]}' 200 return f
'run={self.sync[0]}' 202 return f
'run={self.sync[0]} lumi={self.sync[1]}' 204 return f
'run={self.sync[0]} lumi={self.sync[1]}' 206 return f
'run={self.sync[0]} lumi={self.sync[1]}' 208 return f
'run={self.sync[0]} lumi={self.sync[1]} event={self.sync[2]}' 210 return f
'run={self.sync[0]} lumi={self.sync[1]}' 220 return f
'{transitionName(self.transition)} : id={self.index} {self.syncText()}' 222 return f
'{self.textPrefix()} {self.textSpecial()}: {self.textPostfix()}' 225 for i
in range(len(containers)):
226 if containers[i][-1][
"sync"] == sync:
229 for i
in range(len(containers)):
230 for t
in containers[i]:
231 if t[
"sync"] == sync:
234 print(
"find failed",sync, containers)
239 for i
in range(len(container)):
240 if sync == container[i][
"sync"]:
241 results.append(container[i])
242 results.append(container[i+1])
248 transitionsToFindMatch_ = {
251 Phase.globalWriteRun,
252 Phase.globalWriteLumi
267 if self.
sync[1] == kLargestLumiNumber:
270 container = data.indexedGlobal(index)
271 container[-1][
"finish"] = self.
time*kMicroToSec
273 data._queued[-1][
"finish"] = self.
time*kMicroToSec
279 queued = data._queued
281 container = data.indexedGlobal(index)
284 if last[
"type"]==Phase.globalBeginRun
and last[
"isSrc"]:
285 last[
"sync"]=list(self.
sync)
286 container.append(q[0])
287 container.append(q[1])
291 queued = data._queued
293 container = data.indexedGlobal(index)
296 if last[
"type"]==Phase.globalBeginLumi
and last[
"isSrc"]:
297 last[
"sync"]=list(self.
sync)
298 container.append(q[0])
299 container.append(q[1])
300 elif self.
transition in transitionsToFindMatch_:
302 container = data.indexedGlobal(index)
304 container = data.indexedStream(self.
index)
308 if last[
"type"]==Phase.Event
and last[
"isSrc"]:
309 last[
"sync"]=list(self.
sync)
322 data._queued[-1][
'finish']=self.
time*kMicroToSec
325 container = data.indexedGlobal(index)
327 container = data.indexedStream(self.
index)
328 container[-1][
"finish"]=self.
time*kMicroToSec
338 if self.
sync[1] == kLargestLumiNumber:
348 if self.
transition == Phase.getNextTransition:
363 if self.
transition == Phase.getNextTransition:
369 return f
'source during {transitionName(self.transition)} : id={self.index}' 371 return f
'{self.textPrefix()} {self.textSpecial()}: {self.textPostfix()}' 384 data.findOpenSlotInModGlobals(0,0).
append(data._nextTrans[-1])
387 index = counter.start()
388 container = data.indexedGlobal(index)
391 container = data.indexedStream(index)
394 container = data.indexedGlobal(index)
395 nextTrans = data._nextTrans
401 transStartTime = t[
'start']
403 for i
in range(-1, -1*len(container), -1):
404 if transStartTime > container[i][
'start']:
410 container.insert(i+1,t)
414 container.insert(0,t)
418 data.findOpenSlotInModStreams(index,0).
append(container[-1])
420 data.findOpenSlotInModGlobals(index,0).
append(container[-1])
431 container = data.indexedStream(index)
432 elif self.
transition == Phase.getNextTransition:
433 data._nextTrans[-1][
'finish'] = self.
time*kMicroToSec
437 for i, g
in enumerate(data.allGlobals()):
438 for t
in reversed(g):
439 if t[
"type"] != Phase.construction:
445 pre[
"finish"]=self.
time*kMicroToSec
450 container = data.indexedGlobal(index)
452 container[-1][
"finish"]=self.
time*kMicroToSec
476 return f
'{self.moduleName} during {transitionName(self.transition)} : id={self.index}' 479 return f
' transform {self.callID-1}' 482 return f
'{self.textPrefix(context)} {self.textSpecial()}{self.textIfTransform()}: {self.textPostfix()}' 483 def _preJson(self, activity, counter, data, mayUseTemp = False):
487 compare =
lambda x: x[
'type'] == self.
transition and x[
'id'] == self.
index and x[
'mod'] == self.
moduleID and x[
'call'] == self.
callID and (x[
'act'] == Activity.temporary
or x[
'act'] == Activity.externalWork)
489 item,slot = data.findLastInModGlobals(index, self.
moduleID, compare)
491 item,slot = data.findLastInModStreams(index, self.
moduleID, compare)
493 if item[
'act'] == Activity.temporary:
496 item[
'finish']=self.
time*kMicroToSec
500 slot = data.findOpenSlotInModGlobals(index, self.
moduleID)
502 slot = data.findOpenSlotInModStreams(index, self.
moduleID)
509 item,slot = data.findLastInModGlobals(index, self.
moduleID, compare)
511 item,slot = data.findLastInModStreams(index, self.
moduleID, compare)
513 print(f
"failed to find {self.moduleID} for {self.transition} in {self.index}")
515 item[
"finish"]=self.
time*kMicroToSec
517 slot.append(injectAfter)
524 return "starting action" 532 return "finished action" 541 return "starting prefetch" 544 entry = self.
_preJson(Activity.prefetch, counter,data)
547 kPrefetchLength = 2*kMicroToSec
548 entry[
"finish"]=entry[
"start"]+kPrefetchLength
557 return "finished prefetch" 569 return "starting acquire" 578 return "finished acquire" 589 return "starting delayed get" 591 return self.
_preJson(Activity.delayedGet, counter,data)
597 return "finished delayed get" 605 return "starting read from source" 607 slot = self.
_preJson(Activity.process, counter,data)
615 return "finished read from source" 620 def __init__(self, payload, moduleNames, esModuleNames, recordNames):
644 return f
'esmodule {self.moduleName} in record {self.recordName} during {transitionName(self.transition)} : id={self.index}' 646 return f
'{self.textPrefix(context)} {self.textSpecial()}: {self.textPostfix()}' 650 slot = data.findOpenSlotInModGlobals(index, -1*self.
moduleID)
652 slot = data.findOpenSlotInModStreams(index, -1*self.
moduleID)
656 compare =
lambda x: x[
'id'] == self.
index and x[
'mod'] == -1*self.
moduleID and x[
'call'] == self.
callID 659 item,s = data.findLastInModGlobals(index, -1*self.
moduleID, compare)
661 item,s = data.findLastInModStreams(index, -1*self.
moduleID, compare)
663 print(f
"failed to find {-1*self.moduleID} for {self.transition} in {self.index}")
665 item[
"finish"]=self.
time*kMicroToSec
669 def __init__(self, payload, names, esNames, recordNames):
670 super().
__init__(payload, names, esNames, recordNames)
672 return "starting action" 674 return self.
_preJson(Activity.process, counter,data)
677 def __init__(self, payload, names, esNames, recordNames):
678 super().
__init__(payload, names, esNames, recordNames)
680 return "finished action" 685 def __init__(self, payload, names, esNames, recordNames, moduleCentric):
686 super().
__init__(payload, names, esNames, recordNames)
689 return "starting prefetch" 691 entry = self.
_preJson(Activity.prefetch, counter,data)
693 entry[
"finish"] = entry[
"start"]+2*kMicroToSec;
697 def __init__(self, payload, names, esNames, recordNames, moduleCentric):
698 super().
__init__(payload, names, esNames, recordNames)
701 return "finished prefetch" 709 super().
__init__(payload, names, recordNames)
711 return "starting acquire" 713 return self.
_preJson(Activity.acquire, counter,data)
716 def __init__(self, payload, names, esNames, recordNames):
717 super().
__init__(payload, names, esNames, recordNames)
719 return "finished acquire" 724 def lineParserFactory (step, payload, moduleNames, esModuleNames, recordNames, frameworkOnly, moduleCentric):
727 if parser.transition == Phase.esSyncEnqueue:
776 if not l
or l[0] ==
'#':
778 (step,payload) =
tuple(l.split(
None,1))
779 payload=payload.split()
781 parser =
lineParserFactory(step, payload, moduleNames, esModuleNames, recordNames, frameworkOnly, moduleCentric)
787 def __init__(self,f, frameworkOnly, moduleCentric):
788 streamBeginRun =
str(Phase.streamBeginRun)
790 numStreamsFromSource = 0
796 if l
and l[0] ==
'M':
798 if i[3] == streamBeginRun:
800 numStreams =
int(i[1])+1
802 if numStreams == 0
and l
and l[0] ==
'S':
803 s =
int(l.split(
' ')[1])
804 if s > numStreamsFromSource:
805 numStreamsFromSource = s
806 if len(l) > 5
and l[0:2] ==
"#M":
808 moduleNames[
int(id)] = name
810 if len(l) > 5
and l[0:2] ==
"#N":
812 esModuleNames[
int(id)] = name
814 if len(l) > 5
and l[0:2] ==
"#R":
816 recordNames[
int(id)] = name
823 numStreams = numStreamsFromSource +2
829 for n
in moduleNames.items():
831 for n
in esModuleNames.items():
837 """Create a generator which can step through the file and return each processing step. 838 Using a generator reduces the memory overhead when parsing a large file. 845 for p
in parser.processingSteps():
846 print(p.text(context))
871 while len(container) < index+1:
885 container = fullContainer[index]
887 foundOpenSlot =
False 888 for slot
in container:
892 if slot[-1][
"finish"] != 0:
895 if not foundOpenSlot:
904 container = fullContainer[index]
906 for slot
in container:
907 if comparer(slot[-1]):
908 return (slot[-1],slot)
927 while len(container) < index+1:
931 container.insert(0,[])
948 foundOpenSlot =
False 949 for slot
in container:
953 if slot[-1][
"finish"] != 0:
956 if not foundOpenSlot:
965 if not fullContainer:
972 for slot
in container:
973 if slot
is not None and comparer(slot[-1]):
974 return (slot[-1],slot)
984 return {
"type": type,
"id": id,
"sync": sync,
"start": start*kMicroToSec,
"finish": finish*kMicroToSec,
"isSrc":isSrc}
987 return {
"type": type,
"id": id,
"mod": modID,
"call": callID,
"act": activity,
"start": start*kMicroToSec,
"finish": finish*kMicroToSec}
993 if parser._moduleCentric:
997 for p
in parser.processingSteps():
998 p.jsonInfo(counter, data)
1000 for g
in data.allGlobals():
1001 g.sort(key=startTime)
1002 final = {
"transitions" : [] ,
"modules": [],
"esModules": []}
1003 final[
"transitions"].
append({
"name":
"Global",
"slots": []})
1004 globals = final[
"transitions"][-1][
"slots"]
1005 for i, g
in enumerate(data.allGlobals()):
1007 if not parser._moduleCentric
and not parser._frameworkOnly:
1008 if len(data._modGlobals) < i+1:
1010 for mod
in data._modGlobals[i]:
1012 for i,s
in enumerate(data.allStreams()):
1013 final[
"transitions"].
append({
"name": f
"Stream {i}",
"slots":[]})
1014 stream = final[
"transitions"][-1][
"slots"]
1016 if not parser._moduleCentric
and not parser._frameworkOnly:
1017 for mod
in data._modStreams[i]:
1019 if parser._moduleCentric:
1020 sourceSlot = data._modules[data._moduleID2Index(0)]
1022 for i,m
in parser._moduleNames.items():
1023 modules.append({
"name": f
"{m}",
"slots":[]})
1024 slots = modules[-1][
"slots"]
1025 foundSlots = data._modules[data._moduleID2Index(i)]
1027 for s
in foundSlots:
1030 if t[
"act"] !=Activity.prefetch:
1031 time += t[
"finish"]-t[
"start"]
1032 modules[-1][
'time']=time
1033 for i,m
in parser._esModuleNames.items():
1034 modules.append({
"name": f
"{m}",
"slots":[]})
1035 slots = modules[-1][
"slots"]
1036 foundSlots = data._modules[data._moduleID2Index(-1*i)]
1038 for s
in foundSlots:
1041 if t[
"act"] !=Activity.prefetch:
1042 time += t[
"finish"]-t[
"start"]
1043 modules[-1][
'time']=time
1044 modules.sort(key=
lambda x : x[
'time'], reverse=
True)
1045 final[
'transitions'].
append({
"name":
"source",
"slots":sourceSlot})
1047 final[
'transitions'].
append(m)
1049 if not parser._frameworkOnly:
1051 for k
in parser._moduleNames.keys():
1055 final[
"modules"] =[
'']*(max+1)
1056 final[
"modules"][0] =
'source' 1057 for k,v
in parser._moduleNames.items():
1058 final[
"modules"][k]=v
1061 for k
in parser._esModuleNames.keys():
1064 final[
"esModules"] = [
'']*(max+1)
1065 for k,v
in parser._esModuleNames.items():
1066 final[
"esModules"][k] = v
1078 class TestModuleCommand(unittest.TestCase):
1090 f
'F {Phase.startTracing} 0 0 0 0 {incr(t)}',
1091 f
'S {Phase.construction} 0 {incr(t)}',
1092 f
's {Phase.construction} 0 {incr(t)}3',
1093 f
'M {Phase.construction} 0 1 0 0 0 {incr(t)}',
1094 f
'm {Phase.construction} 0 1 0 0 0 {incr(t)}',
1095 f
'F {Phase.beginJob} 0 0 0 0 {incr(t)}',
1096 f
'M {Phase.beginJob} 0 1 0 0 0 {incr(t)}',
1097 f
'm {Phase.beginJob} 0 1 0 0 0 {incr(t)}',
1098 f
'f {Phase.beginJob} 0 0 0 0 {incr(t)}',
1099 f
'F {Phase.beginProcessBlock} 0 0 0 0 {incr(t)}',
1100 f
'f {Phase.beginProcessBlock} 0 0 0 0 {incr(t)}',
1101 f
'S {Phase.getNextTransition} {incr(t)}',
1102 f
's {Phase.getNextTransition} {incr(t)}',
1103 f
'F {Phase.esSyncEnqueue} -1 1 0 0 {incr(t)}',
1104 f
'F {Phase.esSync} -1 1 0 0 {incr(t)}',
1105 f
'f {Phase.esSync} -1 1 0 0 {incr(t)}',
1106 f
'S {Phase.globalBeginRun} 0 {incr(t)}',
1107 f
's {Phase.globalBeginRun} 0 {incr(t)}',
1108 f
'S {Phase.getNextTransition} {incr(t)}',
1109 f
's {Phase.getNextTransition} {incr(t)}',
1110 f
'F {Phase.globalBeginRun} 0 1 0 0 {incr(t)}',
1111 f
'P {Phase.globalBeginRun} 0 1 0 0 0 {incr(t)}',
1112 f
'p {Phase.globalBeginRun} 0 1 0 0 0 {incr(t)}',
1113 f
'M {Phase.globalBeginRun} 0 1 0 0 0 {incr(t)}',
1114 f
'm {Phase.globalBeginRun} 0 1 0 0 0 {incr(t)}',
1115 f
'f {Phase.globalBeginRun} 0 1 0 0 {incr(t)}',
1116 f
'F {Phase.esSyncEnqueue} -1 1 1 0 {incr(t)}',
1117 f
'F {Phase.esSync} -1 1 1 0 {incr(t)}',
1118 f
'f {Phase.esSync} -1 1 1 0 {incr(t)}',
1119 f
'S {Phase.getNextTransition} {incr(t)}',
1120 f
's {Phase.getNextTransition} {incr(t)}',
1121 f
'F {Phase.streamBeginRun} 0 1 0 0 {incr(t)}',
1122 f
'M {Phase.streamBeginRun} 0 1 0 0 0 {incr(t)}',
1123 f
'm {Phase.streamBeginRun} 0 1 0 0 0 {incr(t)}',
1124 f
'f {Phase.streamBeginRun} 0 1 0 0 {incr(t)}',
1125 f
'F {Phase.streamBeginRun} 1 1 0 0 {incr(t)}',
1126 f
'M {Phase.streamBeginRun} 1 1 0 0 0 {incr(t)}',
1127 f
'm {Phase.streamBeginRun} 1 1 0 0 0 {incr(t)}',
1128 f
'f {Phase.streamBeginRun} 1 1 0 0 {incr(t)}',
1129 f
'S {Phase.globalBeginLumi} 0 {incr(t)}',
1130 f
's {Phase.globalBeginLumi} 0 {incr(t)}',
1131 f
'S {Phase.getNextTransition} {incr(t)}',
1132 f
's {Phase.getNextTransition} {incr(t)}',
1133 f
'F {Phase.globalBeginLumi} 0 1 1 0 {incr(t)}',
1134 f
'P {Phase.globalBeginLumi} 0 1 0 0 0 {incr(t)}',
1135 f
'p {Phase.globalBeginLumi} 0 1 0 0 0 {incr(t)}',
1136 f
'M {Phase.globalBeginLumi} 0 1 0 0 0 {incr(t)}',
1137 f
'm {Phase.globalBeginLumi} 0 1 0 0 0 {incr(t)}',
1138 f
'f {Phase.globalBeginLumi} 0 1 1 0 {incr(t)}',
1139 f
'F {Phase.streamBeginLumi} 0 1 1 0 {incr(t)}',
1140 f
'f {Phase.streamBeginLumi} 0 1 1 0 {incr(t)}',
1141 f
'F {Phase.streamBeginLumi} 1 1 1 0 {incr(t)}',
1142 f
'f {Phase.streamBeginLumi} 1 1 1 0 {incr(t)}',
1143 f
'S {Phase.Event} 0 {incr(t)}',
1144 f
's {Phase.Event} 0 {incr(t)}',
1145 f
'S {Phase.getNextTransition} {incr(t)}',
1146 f
's {Phase.getNextTransition} {incr(t)}',
1147 f
'F {Phase.Event} 0 1 1 1 {incr(t)}',
1148 f
'S {Phase.Event} 1 {incr(t)}',
1149 f
's {Phase.Event} 1 {incr(t)}',
1150 f
'F {Phase.Event} 1 1 1 2 {incr(t)}',
1151 f
'P {Phase.Event} 0 1 0 0 0 {incr(t)}',
1152 f
'p {Phase.Event} 0 1 0 0 0 {incr(t)}',
1153 f
'Q {Phase.Event} 0 1 1 0 1 0 {incr(t)}',
1154 f
'q {Phase.Event} 0 1 1 0 1 0 {incr(t)}',
1155 f
'N {Phase.Event} 0 1 1 0 1 0 {incr(t)}',
1156 f
'n {Phase.Event} 0 1 1 0 1 0 {incr(t)}',
1157 f
'P {Phase.Event} 1 1 0 0 0 {incr(t)}',
1158 f
'p {Phase.Event} 1 1 0 0 0 {incr(t)}',
1159 f
'M {Phase.Event} 0 1 0 0 0 {incr(t)}',
1160 f
'M {Phase.Event} 1 1 0 0 0 {incr(t)}',
1161 f
'm {Phase.Event} 1 1 0 0 0 {incr(t)}',
1162 f
'm {Phase.Event} 0 1 0 0 0 {incr(t)}',
1163 f
'f {Phase.Event} 0 1 1 1 {incr(t)}',
1164 f
'f {Phase.Event} 1 1 1 2 {incr(t)}'])
1170 self.assertEqual(len(c.allGlobals()), 3)
1172 self.assertEqual(len(c.allStreams()), 3)
1173 slot = c.findOpenSlotInModGlobals(2, 1)
1174 self.assertEqual(len(c._modGlobals),3)
1175 self.assertEqual(len(slot),0)
1176 slot.append({
"start":1,
"finish":0,
"id":1})
1178 return item[
"id"]==1
1179 item,s = c.findLastInModGlobals(2, 1, testFind)
1180 self.assertEqual(item[
"id"],1)
1181 self.assertEqual(slot,s)
1182 slot = c.findOpenSlotInModStreams(2, 1)
1183 self.assertEqual(len(c._modStreams),3)
1184 self.assertEqual(len(slot),0)
1185 slot.append({
"start":1,
"finish":0,
"id":1})
1186 item,s = c.findLastInModStreams(2, 1, testFind)
1187 self.assertEqual(item[
"id"],1)
1188 self.assertEqual(slot,s)
1193 self.assertEqual(len(j[
"modules"]), 0)
1194 self.assertEqual(len(j[
"esModules"]), 0)
1195 self.assertEqual(len(j[
'transitions']), 3)
1196 self.assertEqual(j[
'transitions'][0][
'name'],
"Global")
1197 self.assertEqual(j[
'transitions'][1][
'name'],
"Stream 0")
1198 self.assertEqual(j[
'transitions'][2][
'name'],
"Stream 1")
1199 self.assertEqual(len(j[
"transitions"][0][
"slots"]), 1)
1200 self.assertEqual(len(j[
"transitions"][0][
"slots"][0]), 15)
1201 self.assertEqual(len(j[
"transitions"][1][
"slots"]), 1)
1202 self.assertEqual(len(j[
"transitions"][1][
"slots"][0]), 5)
1203 self.assertEqual(len(j[
"transitions"][2][
"slots"]), 1)
1204 self.assertEqual(len(j[
"transitions"][2][
"slots"][0]), 5)
1209 self.assertEqual(len(j[
"modules"]), 2)
1210 self.assertEqual(len(j[
"esModules"]), 2)
1211 self.assertEqual(len(j[
'transitions']), 3)
1212 self.assertEqual(j[
'transitions'][0][
'name'],
"Global")
1213 self.assertEqual(j[
'transitions'][1][
'name'],
"Stream 0")
1214 self.assertEqual(j[
'transitions'][2][
'name'],
"Stream 1")
1215 self.assertEqual(len(j[
"transitions"][0][
"slots"]), 2)
1216 self.assertEqual(len(j[
"transitions"][0][
"slots"][0]), 15)
1217 self.assertEqual(len(j[
"transitions"][0][
"slots"][1]), 6)
1218 self.assertEqual(len(j[
"transitions"][1][
"slots"]), 2)
1219 self.assertEqual(len(j[
"transitions"][1][
"slots"][0]), 5)
1220 self.assertEqual(len(j[
"transitions"][1][
"slots"][1]), 5)
1221 self.assertEqual(len(j[
"transitions"][2][
"slots"]), 2)
1222 self.assertEqual(len(j[
"transitions"][2][
"slots"][0]), 5)
1223 self.assertEqual(len(j[
"transitions"][2][
"slots"][1]), 3)
1228 self.assertEqual(len(j[
"modules"]), 2)
1229 self.assertEqual(len(j[
"esModules"]), 2)
1230 self.assertEqual(len(j[
'transitions']), 6)
1231 self.assertEqual(j[
'transitions'][0][
'name'],
"Global")
1232 self.assertEqual(j[
'transitions'][1][
'name'],
"Stream 0")
1233 self.assertEqual(j[
'transitions'][2][
'name'],
"Stream 1")
1234 self.assertEqual(j[
'transitions'][3][
'name'],
"source")
1235 self.assertEqual(j[
'transitions'][4][
'name'],
"Module")
1236 self.assertEqual(j[
'transitions'][5][
'name'],
"ESModule")
1237 self.assertEqual(len(j[
"transitions"][0][
"slots"]), 1)
1238 self.assertEqual(len(j[
"transitions"][0][
"slots"][0]), 15)
1239 self.assertEqual(len(j[
"transitions"][1][
"slots"]), 1)
1240 self.assertEqual(len(j[
"transitions"][1][
"slots"][0]), 5)
1241 self.assertEqual(len(j[
"transitions"][2][
"slots"]), 1)
1242 self.assertEqual(len(j[
"transitions"][2][
"slots"][0]), 5)
1243 self.assertEqual(len(j[
"transitions"][4][
"slots"]), 2)
1244 self.assertEqual(len(j[
"transitions"][4][
"slots"][0]), 10)
1245 self.assertEqual(len(j[
"transitions"][4][
"slots"][1]), 2)
1246 self.assertTrue(j[
"transitions"][4][
"slots"][1][-1][
'finish'] != 0.0)
1247 self.assertEqual(len(j[
"transitions"][5][
"slots"]), 1)
1248 self.assertEqual(len(j[
"transitions"][5][
"slots"][0]), 2)
1251 return unittest.main(argv=sys.argv[:1])
1254 if __name__==
"__main__":
1260 parser = argparse.ArgumentParser(description=
'Convert a compact tracer file into human readable output.',
1261 formatter_class=argparse.RawDescriptionHelpFormatter,
1263 parser.add_argument(
'filename',
1264 type=argparse.FileType(
'r'), # open file 1265 help='file to process')
1266 parser.add_argument(
'-f',
'--frameworkOnly',
1267 action=
'store_true',
1268 help=
'''Output only the framework transitions, excluding the individual module transitions.''')
1269 parser.add_argument(
'-j',
'--json',
1270 action=
'store_true',
1271 help=
'''Write output in json format.''' )
1272 parser.add_argument(
'-w',
'--web',
1273 action=
'store_true',
1274 help=
'''Writes data.js file that can be used with the web based inspector. To use, copy directory ${CMSSW_RELEASE_BASE}/src/FWCore/Services/template/web to a web accessible area and move data.js into that directory.''')
1275 parser.add_argument(
'-m',
'--module_centric',
1276 action =
'store_true',
1277 help=
'''For --json or --web, organize data by module instead of by global/stream.''' )
1278 parser.add_argument(
'-t',
'--test',
1279 action=
'store_true',
1280 help=
'''Run internal tests.''')
1282 args = parser.parse_args()
1287 if args.json
or args.web:
1292 j =
'export const data = ' + j
1293 f=open(
'data.js',
'w')
def __init__(self, payload, moduleNames)
def indexedGlobal(self, index)
def jsonInfo(self, counter, data)
def __init__(self, payload, names, moduleCentric)
def _preJson(self, activity, counter, data, mayUseTemp=False)
def processingSteps(self)
def processingStepsFromFile(f, moduleNames, esModuleNames, recordNames, frameworkOnly, moduleCentric)
def __init__(self, payload, names, esNames, recordNames, moduleCentric)
def jsonInfo(self, counter, data)
def jsonInfo(self, counter, data)
def jsonInfo(self, counter, data)
def findOpenSlotInModGlobals(self, index, modID)
def _postJson(self, counter, data, injectAfter=None)
def jsonTransition(type, id, sync, start, finish, isSrc=False)
def findLastInModStreams(self, index, modID, comparer)
def __init__(self, payload, names, moduleCentric)
def indexedGlobal(self, index)
def __init__(self, f, frameworkOnly, moduleCentric)
def transitionName(transition)
def jsonInfo(self, counter, data)
def __init__(self, payload)
def __init__(self, payload)
def textPrefix(self, context)
def jsonInfo(self, counter, data)
def jsonInfo(self, counter, data)
def __init__(self, payload, names)
def jsonInfo(self, counter, data)
def __init__(self, payload, moduleCentric)
def __init__(self, payload, names, recordNames)
def _findOpenSlot(self, index, fullContainer)
def jsonInfo(self, counter, data)
def lineParserFactory(step, payload, moduleNames, esModuleNames, recordNames, frameworkOnly, moduleCentric)
def __init__(self, payload, names, esNames, recordNames)
def __init__(self, payload, names, esNames, recordNames, moduleCentric)
def baseIndentLevel(self)
def _extendIfNeeded(self, container, index)
def transitionIsGlobal(transition)
def findLastInModGlobals(self, index, modID, comparer)
def __init__(self, payload, names)
def jsonModuleTransition(type, id, modID, callID, activity, start, finish=0)
def _preJson(self, activity, counter, data)
def _extendModulesIfNeeded(self, container, index)
def __init__(self, payload, names)
def jsonInfo(self, counter, data)
def _postJson(self, counter, data)
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
def jsonInfo(self, counter, data)
def _findLastIn(self, index, fullContainer, comparer)
def jsonInfo(self, counter, data)
def jsonInfo(self, counter, data)
def baseIndentLevel(self)
def findMatchingTransition(sync, containers)
def textPrefix_(time, indentLevel)
def split(sequence, size)
def _moduleID2Index(self, modID)
def _findOpenSlot(self, index, fullContainer)
def __init__(self, payload, names)
def __init__(self, payload, names)
def jsonInfo(self, counter, data)
def testModuleCentric(self)
def __init__(self, payload, moduleNames, esModuleNames, recordNames)
def transitionIndentLevel(transition)
def findOpenSlotInModGlobals(self, index, modID)
def __init__(self, payload, names, moduleCentric)
def findOpenSlotInModStreams(self, index, modID)
def findLastInModStreams(self, index, modID, comparer)
def indexedStream(self, index)
def findOpenSlotInModStreams(self, index, modID)
def testFrameworkOnly(self)
def _extendIfNeeded(self, container, index)
def __init__(self, payload, names, moduleCentric)
def __init__(self, payload)
def __init__(self, payload, names, moduleCentric)
def jsonInfo(self, counter, data)
def jsonInfo(self, counter, data)
def jsonInfo(self, counter, data)
def __init__(self, payload, names, esNames, recordNames)
def textIfTransform(self)
def _findLastIn(self, index, fullContainer, comparer)
def __init__(self, payload, moduleCentric)
def jsonInfo(self, counter, data)
def findLastInModGlobals(self, index, modID, comparer)
def popQueuedTransitions(sync, container)
def jsonInfo(self, counter, data)
def __init__(self, payload)
def jsonInfo(self, counter, data)
def jsonInfo(self, counter, data)
def indexedStream(self, index)
def textPrefix(self, context)
def __init__(self, payload)
def __init__(self, payload, names, esNames, recordNames)