1 | """ |
---|
2 | Script to measure how long pmesh spends doing various methods |
---|
3 | """ |
---|
4 | from mesh import * |
---|
5 | from anuga.pmesh import * |
---|
6 | import time |
---|
7 | |
---|
8 | def 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() |
---|
31 | n = 2 |
---|
32 | maxArea = 0.00005 |
---|
33 | #maxArea = 0.1 |
---|
34 | times = [] |
---|
35 | tinitial = time.time() |
---|
36 | mem_initial = mem_usage() |
---|
37 | print "mem_initial", mem_initial |
---|
38 | #------------------------------------------ |
---|
39 | mesh = Mesh() |
---|
40 | id = 0 |
---|
41 | for i in range(n): |
---|
42 | for j in range(n): |
---|
43 | v = mesh.addUserVertex(i,j) |
---|
44 | v.guiID = id |
---|
45 | id += 1 |
---|
46 | v1 = mesh.addUserVertex(-1,-1) |
---|
47 | v1.guiID = id |
---|
48 | id += 1 |
---|
49 | v2 = mesh.addUserVertex(-1,n) |
---|
50 | v2.guiID = id |
---|
51 | id += 1 |
---|
52 | v3 = mesh.addUserVertex(n,n) |
---|
53 | v3.guiID = id |
---|
54 | id += 1 |
---|
55 | v4 = mesh.addUserVertex(n,-1) |
---|
56 | v4.guiID = id |
---|
57 | id += 1 |
---|
58 | mesh.addUserSegment(v1,v2) |
---|
59 | mesh.addUserSegment(v2,v3) |
---|
60 | mesh.addUserSegment(v3,v4) |
---|
61 | mesh.addUserSegment(v4,v1) |
---|
62 | mem_now =mem_usage() |
---|
63 | #print "mem_now", mem_now |
---|
64 | if mem_now is not None: |
---|
65 | mem = mem_now - mem_initial |
---|
66 | else: |
---|
67 | mem = 0.0 |
---|
68 | times.append(("user_outline_created",time.time() - tinitial, mem )) |
---|
69 | #------------------------------------------ |
---|
70 | mesh.generateMesh(mode = "Q",maxArea = maxArea) |
---|
71 | mem_now =mem_usage() |
---|
72 | #print "mem_now", mem_now |
---|
73 | if mem_now is not None: |
---|
74 | mem = mem_now - mem_initial |
---|
75 | else: |
---|
76 | mem = 0.0 |
---|
77 | times.append(("mesh_generated",time.time()- tinitial - times[0][1], mem)) |
---|
78 | #------------------------------------------ |
---|
79 | mesh.export_mesh_file("dump.msh") |
---|
80 | mem_now =mem_usage() |
---|
81 | #print "mem_now", mem_now |
---|
82 | if mem_now is not None: |
---|
83 | mem = mem_now - mem_initial |
---|
84 | else: |
---|
85 | mem = 0.0 |
---|
86 | times.append(("export_mesh_file",time.time()- tinitial - times[1][1], mem)) |
---|
87 | |
---|
88 | #--------------------- |
---|
89 | print "Number of user verts. ", n |
---|
90 | print "maxArea",maxArea |
---|
91 | print "funtion time memory usage, cumulative, for nix machines" |
---|
92 | for 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 1497 |
---|
105 | Number of user verts. 2 |
---|
106 | maxArea 0.0001 |
---|
107 | user_outline_created 0.00 |
---|
108 | mesh_generated 4.92 |
---|
109 | export_mesh_file 16.30 |
---|
110 | |
---|
111 | Number of user verts. 2 |
---|
112 | maxArea 0.0001 |
---|
113 | user_outline_created 0.00 |
---|
114 | mesh_generated 4.92 |
---|
115 | export_mesh_file 16.30 |
---|
116 | |
---|
117 | Number of user verts. 2 |
---|
118 | maxArea 5e-005 |
---|
119 | user_outline_created 0.00 |
---|
120 | mesh_generated 15.53 |
---|
121 | export_mesh_file 41.39 |
---|
122 | |
---|
123 | version 4903 |
---|
124 | mem_initial None |
---|
125 | Number of user verts. 2 |
---|
126 | maxArea 5e-005 |
---|
127 | funtion time memory usage, cumulative, for nix machines |
---|
128 | user_outline_created 0.49 0.00 |
---|
129 | mesh_generated 1.94 0.00 |
---|
130 | export_mesh_file 2.75 0.00 |
---|
131 | |
---|
132 | |
---|
133 | Results of tornado head node |
---|
134 | Number of user verts. 2 |
---|
135 | maxArea 5e-05 |
---|
136 | funtion time memory usage, cumulative, for nix machines |
---|
137 | user_outline_created 0.14 32.00 |
---|
138 | mesh_generated 18.81 378304.00 |
---|
139 | export_mesh_file 17.79 380620.00 |
---|
140 | |
---|
141 | version 4903 |
---|
142 | mem_initial 77816 |
---|
143 | Number of user verts. 2 |
---|
144 | maxArea 5e-05 |
---|
145 | funtion time memory usage, cumulative, for nix machines |
---|
146 | user_outline_created 0.15 32.00 |
---|
147 | mesh_generated 1.26 27224.00 |
---|
148 | export_mesh_file 0.82 27224.00 |
---|
149 | |
---|
150 | """ |
---|