From f092a065cbc9eab7f1465da0d80e8571470b295e Mon Sep 17 00:00:00 2001 From: Anthony Geay Date: Sun, 28 Jan 2024 19:46:14 +0100 Subject: [PATCH] [EDF29150] : WIP --- src/Container/SALOME_ContainerHelper.py | 45 +++++++++++++++++++++++++ 1 file changed, 45 insertions(+) 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 -- 2.39.2