From: Anthony Geay Date: Sun, 28 Jan 2024 18:46:14 +0000 (+0100) Subject: [EDF29150] : WIP X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=f092a065cbc9eab7f1465da0d80e8571470b295e;p=modules%2Fkernel.git [EDF29150] : WIP --- diff --git a/src/Container/SALOME_ContainerHelper.py b/src/Container/SALOME_ContainerHelper.py index 24bbba907..eb8490c5d 100644 --- a/src/Container/SALOME_ContainerHelper.py +++ b/src/Container/SALOME_ContainerHelper.py @@ -196,6 +196,10 @@ class ScriptExecInfo: def endExecTime(self,value): self._end_exec_time = value + @property + def execTime(self): + return self.endExecTime - self.startExecTime + @property def startOutputTime(self): return self._start_output_time @@ -225,6 +229,11 @@ class ScriptExecInfo: return ScriptExecInfo.GetRepresentationOfTimeDelta(self.endOutputTime,self.startOutputTime) def __str__(self): + CPUMemDuringExecForStr = self.CPUMemDuringExecStr + if len > 30: + CPUMemDuringExecForStr = "{} ...".format( str(CPUMemDuringExecForStr) ) + else: + CPUMemDuringExecForStr = str( CPUMemDuringExecForStr ) return """start exec time = {self.startExecTime} end exec time = {self.endExecTime} exec_time = {self.execTimeStr} @@ -521,3 +530,39 @@ def unserializeLogManager(structData): if int(offset) != len(structData): raise RuntimeError("Something went wrong during unserialization phase.") return logManagerInst + +def ListAllExecContainIn( listOfContainerLogInfo ): + """ + For all ContainerLogInfo contained in listOfContainerLogInfo extract all ScriptExecInfo contained recursively + in it. + + Args: + ----- + + listOfContainerLogInfo (list) : instance typically returned by salome.LogManagerLoadFromFile + + Returns + ------- + + list : all ScriptExecInfoDeco instance contained recursively in all input ContainerLogInfo instances + + """ + return sum( [sum( [[myexec for myexec in ps] for ps in cont],[] ) for cont in listOfContainerLogInfo], [] ) + +def IsExecTimeHigherThan( execInstDeco, limitDuration ): + """ + Example of Usage : + + [elt for elt in allexecs if IsExecTimeHigherThan(elt,datetime.timedelta(hours=1))] + + Args: + ----- + + execInstDeco (ScriptExecInfoDeco) + limitDuration (datetime.timedelta) Ex (datetime.timedelta(hours=1)) + + """ + if execInstDeco.get() is not None: + return execInstDeco.get().execTime > limitDuration + else: + return False \ No newline at end of file