source: anuga_core/source/anuga/pmesh/timing.py @ 5521

Last change on this file since 5521 was 5097, checked in by duncan, 17 years ago

Tweaks to icons

File size: 3.7 KB
Line 
1"""
2Script to measure how long pmesh spends doing various methods
3"""
4from mesh import *
5from anuga.pmesh import *
6import time
7 
8def mem_usage():
9    '''
10    returns the rss.
11
12  RSS  The total amount of physical memory used by  the  task,  in  kilo-
13            bytes,  is  shown  here.  For ELF processes used library pages are
14            counted here, for a.out processes not.
15           
16    Only works on nix systems.
17    '''
18    import string
19    p=os.popen('ps uwp %s'%os.getpid()) 
20    lines=p.readlines()
21    #print "lines", lines
22    status=p.close() 
23    if status or len(lines)!=2 or sys.platform == 'win32': 
24        return None 
25    return int(string.split(lines[1])[4]) 
26
27
28
29#draw = Draw()
30#draw.run()
31n = 2
32maxArea = 0.00005
33#maxArea = 0.1
34times = []
35tinitial = time.time()
36mem_initial = mem_usage()
37print "mem_initial", mem_initial
38#------------------------------------------
39mesh = Mesh()
40id = 0
41for i in range(n):
42    for j in range(n):
43       v = mesh.addUserVertex(i,j)
44       v.guiID = id
45       id += 1
46v1 = mesh.addUserVertex(-1,-1)
47v1.guiID = id
48id += 1
49v2 = mesh.addUserVertex(-1,n)
50v2.guiID = id
51id += 1
52v3 = mesh.addUserVertex(n,n)
53v3.guiID = id
54id += 1
55v4 = mesh.addUserVertex(n,-1)
56v4.guiID = id
57id += 1
58mesh.addUserSegment(v1,v2)
59mesh.addUserSegment(v2,v3)
60mesh.addUserSegment(v3,v4)
61mesh.addUserSegment(v4,v1)
62mem_now =mem_usage()
63#print "mem_now", mem_now
64if mem_now is not None:
65    mem = mem_now - mem_initial
66else:
67    mem = 0.0
68times.append(("user_outline_created",time.time() - tinitial, mem ))
69#------------------------------------------
70mesh.generateMesh(mode = "Q",maxArea = maxArea)
71mem_now =mem_usage()
72#print "mem_now", mem_now
73if mem_now is not None:
74    mem = mem_now - mem_initial
75else:
76    mem = 0.0
77times.append(("mesh_generated",time.time()- tinitial - times[0][1], mem))
78#------------------------------------------
79mesh.export_mesh_file("dump.msh")
80mem_now =mem_usage()
81#print "mem_now", mem_now
82if mem_now is not None:
83    mem = mem_now - mem_initial
84else:
85    mem = 0.0
86times.append(("export_mesh_file",time.time()- tinitial - times[1][1], mem))
87
88#---------------------
89print "Number of user verts. ", n
90print "maxArea",maxArea
91print "funtion     time   memory usage, cumulative, for nix machines"
92for time in times:
93    print "%s   %0.2f   %0.2f" %(time[0],  time[1], time[2])
94
95"""
96#Results - mesh.py ver   1.84           1.85   
97# N     400     
98# initial                       0               0
99# user_outline_created  1.467999935     1.609999895
100# mesh_generated        21.70300007     22.3440001
101#zoomed                 32.81299996     33.5940001
102
103# results on dsg's pc dell precision 390.
104# anuga version 4897
105Number of user verts.  2
106maxArea 0.0001
107user_outline_created   0.00
108mesh_generated   4.92
109export_mesh_file   16.30
110
111Number of user verts.  2
112maxArea 0.0001
113user_outline_created   0.00
114mesh_generated   4.92
115export_mesh_file   16.30
116
117Number of user verts.  2
118maxArea 5e-005
119user_outline_created   0.00
120mesh_generated   15.53
121export_mesh_file   41.39
122
123version 4903
124mem_initial None
125Number of user verts.  2
126maxArea 5e-005
127funtion     time   memory usage, cumulative, for nix machines
128user_outline_created   0.49   0.00
129mesh_generated   1.94   0.00
130export_mesh_file   2.75   0.00
131
132# anuga version 4897
133Results of tornado head node
134Number of user verts.  2
135maxArea 5e-05
136funtion     time   memory usage, cumulative, for nix machines
137user_outline_created   0.14   32.00
138mesh_generated   18.81   378304.00
139export_mesh_file   17.79   380620.00
140
141version 4903
142mem_initial 77816
143Number of user verts.  2
144maxArea 5e-05
145funtion     time   memory usage, cumulative, for nix machines
146user_outline_created   0.15   32.00
147mesh_generated   1.26   27224.00
148export_mesh_file   0.82   27224.00
149
150"""
Note: See TracBrowser for help on using the repository browser.