Package PyFoam :: Package LogAnalysis :: Module ExecutionTimeLineAnalyzer
[hide private]
[frames] | no frames]

Source Code for Module PyFoam.LogAnalysis.ExecutionTimeLineAnalyzer

  1  """Check for Execution-Time information""" 
  2   
  3  import re 
  4   
5 -def executionRegexp():
6 """@Return: The regular expression that parses the execution time 7 depending on the OpenFOAM-Version""" 8 9 if foamVersionNumber()>=(1,3): 10 return "^ExecutionTime = (.+) s ClockTime = (.+) s$" 11 else: 12 return "^ExecutionTime = (.+) s$"
13 14 # from FileLineAnalyzer import FileLineAnalyzer 15 # from TimeLineLineAnalyzer import TimeLineLineAnalyzer 16 17 from GeneralLineAnalyzer import GeneralLineAnalyzer 18 19 from PyFoam.FoamInformation import foamVersionNumber 20
21 -class GeneralExecutionLineAnalyzer(GeneralLineAnalyzer):
22 """Parses lines for the execution time""" 23
24 - def __init__(self,doTimelines=True,doFiles=True):
25 self.hasClock=(foamVersionNumber()>=(1,3)) 26 titles=["cumulated"] 27 if self.hasClock: 28 titles.append("delta") 29 30 GeneralLineAnalyzer.__init__(self,titles=titles,doTimelines=doTimelines,doFiles=doFiles) 31 self.exp=re.compile(executionRegexp()) 32 33 self.exp=re.compile(executionRegexp()) 34 35 self.lastTime=0. 36 if self.hasClock: 37 self.lastClock=0.
38
39 - def startAnalysis(self,match):
40 self.time=float(match.group(1)) 41 if self.hasClock: 42 self.clock=float(match.group(2))
43
44 - def endAnalysis(self,match):
45 self.lastTime = self.time 46 if self.hasClock: 47 self.lastClock = self.clock
48
49 - def addToFiles(self,match):
50 self.files.write("executionTime",self.parent.getTime(),(self.time,self.time-self.lastTime)) 51 52 if self.hasClock: 53 self.files.write("wallClockTime",self.parent.getTime(),(self.clock,self.clock-self.lastClock))
54
55 - def addToTimelines(self,match):
56 self.lines.setValue("cpu",self.time-self.lastTime) 57 58 if self.hasClock: 59 self.lines.setValue("clock",self.clock-self.lastClock)
60
61 -class ExecutionTimeLineAnalyzer(GeneralExecutionLineAnalyzer):
62 """Parses lines for the execution time""" 63
64 - def __init__(self):
65 GeneralExecutionLineAnalyzer.__init__(self,doTimelines=False)
66 67 ## self.exp=re.compile(executionRegexp()) 68 ## self.lastTime=0. 69 70 ## def doAnalysis(self,line): 71 ## """Writes total execution time and time needed since last 72 ## time-step""" 73 ## m=self.exp.match(line) 74 ## if m!=None: 75 ## time=float(m.group(1)) 76 77 ## self.files.write("executionTime",self.parent.getTime(),(time,time-self.lastTime)) 78 79 ## self.lastTime = time 80
81 -class TimeLineExecutionTimeLineAnalyzer(GeneralExecutionLineAnalyzer):
82 """Parses lines for the execution time""" 83
84 - def __init__(self):
85 GeneralExecutionLineAnalyzer.__init__(self,doFiles=False)
86 87 ## self.hasClock=(foamVersionNumber()>=(1,3)) 88 89 ## self.exp=re.compile(executionRegexp()) 90 91 ## self.lastTime=0. 92 ## if self.hasClock: 93 ## self.lastClock=0. 94 95 ## def doAnalysis(self,line): 96 ## """Writes total execution time and time needed since last 97 ## time-step""" 98 ## m=self.exp.match(line) 99 ## if m!=None: 100 ## time=float(m.group(1)) 101 ## if self.hasClock: 102 ## clock=float(m.group(2)) 103 104 ## self.lines.setValue("cpu",time-self.lastTime) 105 ## self.lastTime = time 106 107 ## if self.hasClock: 108 ## self.lines.setValue("clock",clock-self.lastClock) 109 ## self.lastClock = clock 110