Some timing tests of the Python API. #708
Replies: 4 comments 4 replies
-
Thanks! Of course that's pretty all the Clipper2 lib anyway - I'll be quite interested to see what you find for 3D, since that's our code. |
Beta Was this translation helpful? Give feedback.
-
@elalish OK, you got me curious, so I did the 3d version. The reason the creation from mesh is shorter is that the mesh is a mesh object. Still, clearly fast enough. 3d hull time is bad, not sure what it is that makes 3d hulls so much harder than 2d hulls. But WOW, the batch_boolean time. Anyway, here's the result's:
import time
import manifold3d as m
from random import random
ts = time.time()
for i in range(100000):
c = m.Manifold.cube((10.0, 10.0, 10.0))
te = time.time()
tdiff = te - ts
print(f"{tdiff: 5.3f}", "100,000 creations of M with cube member function")
mesh = c.to_mesh()
ts = time.time()
for i in range(100000):
c = m.Manifold(mesh).to_mesh()
te = time.time()
tdiff = te - ts
print(f"{tdiff: 5.3f}", "100,000 creations of M with mesh from cube")
r = 5
s = 36
ts = time.time()
for i in range(1000):
sph = m.Manifold.sphere(r, s)
c = m.Manifold.batch_hull(
[
sph,
sph.translate((10, 0, 0)),
sph.translate((0, 10, 0)),
sph.translate((10, 10, 0)),
sph.translate((0, 0, 10)),
sph.translate((10, 0, 10)),
sph.translate((0, 10, 10)),
sph.translate((10, 10, 10)),
]
)
te = time.time()
tdiff = te - ts
print(f"{tdiff: 5.3f}", "1,000 creations of roundedbox using hull and 8 spheres")
n = 100000
l = []
ts = time.time()
for i in range(n):
c1 = c.translate((random() * 200, random() * 200, random() * 200))
l.append(c1)
te = time.time()
tdiff = te - ts
print(f"{tdiff: 5.3f}", f"Creation of {n} randomly placed roundedbox")
c1 = m.Manifold()
ts = time.time()
for i in range(n//10):
c1 = m.Manifold.__add__(c1, l[i])
te = time.time()
tdiff = te - ts
print(f"{tdiff: 5.3f}", f"{n//10} unions of {n//10} randomly placed roundedbox")
ts = time.time()
c = m.Manifold.batch_boolean(l, m.OpType.Add)
te = time.time()
tdiff = te - ts
print(f"{tdiff: 5.3f}", f"batch_boolean union of {n} randomly placed roundedbox") |
Beta Was this translation helpful? Give feedback.
-
@pca006132 @elalish I updated the numbers and the code above. |
Beta Was this translation helpful? Give feedback.
-
Moving this to #383 (as requested). |
Beta Was this translation helpful? Give feedback.
-
Recently, I was concerned that the union done at the create of a CrossSection could be a problem.
I was completely wrong. From the timing test below and some other experimentation,
I can say that for < 100 vertices the overhead is somewhere between 2.5 and 5.
And everything is so fast, you'd have to be really huge to even notice
I can see no reason for a need to drop to C++ to make CrossSections.
Surprisingly, creation of round rects with hull and 4 circles is quite practical, even for large numbers.
And finally batch_boolean is 2 orders of magnitude faster on a large data set.
All of this was 2D. I'll likely do something for 3D later.
(Times [left column] are in seconds.)
Beta Was this translation helpful? Give feedback.
All reactions