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

Source Code for Module PyFoam.LogAnalysis.ExecutionTimeLineAnalyzer

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