yade-dev team mailing list archive
-
yade-dev team
-
Mailing list archive
-
Message #07293
[Branch ~yade-dev/yade/trunk] Rev 2789: 1.Add utils.trackPerfomance; 2.Small fix
------------------------------------------------------------
revno: 2789
committer: Sergei D. <sega@think>
branch nick: yade
timestamp: Thu 2011-03-17 18:50:01 +0300
message:
1.Add utils.trackPerfomance; 2.Small fix
modified:
py/pack/pack.py
py/utils.py
--
lp:yade
https://code.launchpad.net/~yade-dev/yade/trunk
Your team Yade developers is subscribed to branch lp:yade.
To unsubscribe from this branch go to https://code.launchpad.net/~yade-dev/yade/trunk/+edit-subscription
=== modified file 'py/pack/pack.py'
--- py/pack/pack.py 2011-02-23 10:28:42 +0000
+++ py/pack/pack.py 2011-03-17 15:50:01 +0000
@@ -176,7 +176,7 @@
def gtsSurface2Facets(surf,**kw):
"""Construct facets from given GTS surface. **kw is passed to utils.facet."""
import gts
- return [utils.facet([v.coords() for v in face.vertices()],**kw) for face in surf]
+ return [utils.facet([v.coords() for v in face.vertices()],**kw) for face in surf.faces()]
def sweptPolylines2gtsSurface(pts,threshold=0,capStart=False,capEnd=False):
"""Create swept suface (as GTS triangulation) given same-length sequences of points (as 3-tuples).
=== modified file 'py/utils.py'
--- py/utils.py 2011-03-17 12:56:51 +0000
+++ py/utils.py 2011-03-17 15:50:01 +0000
@@ -544,6 +544,38 @@
return voxelPorosity(resolution,a,b)
+def trackPerfomance(updateTime=5):
+ """
+ Track perfomance of a simulation. (Experimental)
+ Will create new thread to produce some plots.
+ Useful for track perfomance of long run simulations (in bath mode for example).
+ """
+
+ def __track_perfomance(updateTime):
+ pid=os.getpid()
+ threadsCpu={}
+ lastTime,lastIter=-1,-1
+ while 1:
+ time.sleep(updateTime)
+ if not O.running:
+ lastTime,lastIter=-1,-1
+ continue
+ if lastTime==-1:
+ lastTime=time.time();lastIter=O.iter
+ plot.plots.update({'Iteration':('Perfomance',None,'Bodies','Interactions')})
+ continue
+ curTime=time.time();curIter=O.iter
+ perf=(curIter-lastIter)/(curTime-lastTime)
+ out=subprocess.Popen(['top','-bH','-n1', ''.join(['-p',str(pid)])],stdout=subprocess.PIPE).communicate()[0].splitlines()
+ for s in out[7:-1]:
+ w=s.split()
+ threadsCpu[w[0]]=float(w[8])
+ plot.addData(Iteration=curIter,Iter=curIter,Perfomance=perf,Bodies=len(O.bodies),Interactions=len(O.interactions),**threadsCpu)
+ plot.plots.update({'Iter':threadsCpu.keys()})
+ lastTime=time.time();lastIter=O.iter
+
+ thread.start_new_thread(__track_perfomance,(updateTime))
+
def NormalRestitution2DampingRate(en):
r"""Compute the normal damping rate as a function of the normal coefficient of restitution $e_n$. For $e_n\in\langle0,1\rangle$ damping rate equals