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 | |
---|
9 | draw = Draw() |
---|
10 | #draw.run() |
---|
11 | n = 400 |
---|
12 | times = [] |
---|
13 | tinitial = time.time() |
---|
14 | times.append(("initial",time.time()-tinitial)) |
---|
15 | #------------------------------------------ |
---|
16 | mesh = Mesh() |
---|
17 | id = 0 |
---|
18 | for i in range(n): |
---|
19 | for j in range(n): |
---|
20 | v = mesh.addUserVertex(i,j) |
---|
21 | v.guiID = id |
---|
22 | id += 1 |
---|
23 | v1 = mesh.addUserVertex(-1,-1) |
---|
24 | v1.guiID = id |
---|
25 | id += 1 |
---|
26 | v2 = mesh.addUserVertex(-1,n) |
---|
27 | v2.guiID = id |
---|
28 | id += 1 |
---|
29 | v3 = mesh.addUserVertex(n,n) |
---|
30 | v3.guiID = id |
---|
31 | id += 1 |
---|
32 | v4 = mesh.addUserVertex(n,-1) |
---|
33 | v4.guiID = id |
---|
34 | id += 1 |
---|
35 | mesh.addUserSegment(v1,v2) |
---|
36 | mesh.addUserSegment(v2,v3) |
---|
37 | mesh.addUserSegment(v3,v4) |
---|
38 | mesh.addUserSegment(v4,v1) |
---|
39 | times.append(("user_outline_created",time.time() - tinitial )) |
---|
40 | #------------------------------------------ |
---|
41 | #mesh.auto_segment() |
---|
42 | #times.append(("mesh_auto_segmented",time.time() - tinitial )) |
---|
43 | #------------------------------------------ |
---|
44 | mesh.generateMesh(mode = "Q",maxArea = 1) |
---|
45 | times.append(("mesh_generated",time.time() - tinitial )) |
---|
46 | #------------------------------------------ |
---|
47 | draw.mesh = mesh |
---|
48 | draw.selectZoom(1.0) |
---|
49 | times.append(("zoomed",time.time() - tinitial )) |
---|
50 | #------------------------------------------ |
---|
51 | |
---|
52 | |
---|
53 | #--------------------- |
---|
54 | print "N is ", n |
---|
55 | for time in times: |
---|
56 | print "%s %0.12f" %(time[0], time[1]) |
---|
57 | |
---|
58 | |
---|
59 | #Results - mesh.py ver 1.84 1.85 |
---|
60 | # N 400 |
---|
61 | # initial 0 0 |
---|
62 | # user_outline_created 1.467999935 1.609999895 |
---|
63 | # mesh_generated 21.70300007 22.3440001 |
---|
64 | #zoomed 32.81299996 33.5940001 |
---|
65 | |
---|
66 | |
---|
67 | |
---|