mirror of
https://github.com/gumyr/build123d.git
synced 2025-12-06 02:30:55 -08:00
Merge branch 'dev' of https://github.com/gumyr/build123d into dev
This commit is contained in:
commit
0d533d3f10
2 changed files with 17 additions and 14 deletions
|
|
@ -1,11 +1,11 @@
|
||||||
import pytest
|
import pytest
|
||||||
import importlib
|
|
||||||
from math import sqrt
|
from math import sqrt
|
||||||
from build123d import *
|
from build123d import *
|
||||||
|
|
||||||
|
|
||||||
pytest_benchmark = pytest.importorskip("pytest_benchmark")
|
pytest_benchmark = pytest.importorskip("pytest_benchmark")
|
||||||
|
|
||||||
|
|
||||||
def test_ppp_0101(benchmark):
|
def test_ppp_0101(benchmark):
|
||||||
def model():
|
def model():
|
||||||
"""
|
"""
|
||||||
|
|
@ -616,9 +616,11 @@ def test_ttt_23_02_02(benchmark):
|
||||||
|
|
||||||
benchmark(model)
|
benchmark(model)
|
||||||
|
|
||||||
|
|
||||||
# def test_ttt_23_T_24(benchmark):
|
# def test_ttt_23_T_24(benchmark):
|
||||||
# excluding because it requires sympy
|
# excluding because it requires sympy
|
||||||
|
|
||||||
|
|
||||||
def test_ttt_24_SPO_06(benchmark):
|
def test_ttt_24_SPO_06(benchmark):
|
||||||
def model():
|
def model():
|
||||||
densa = 7800 / 1e6 # carbon steel density g/mm^3
|
densa = 7800 / 1e6 # carbon steel density g/mm^3
|
||||||
|
|
@ -675,3 +677,17 @@ def test_ttt_24_SPO_06(benchmark):
|
||||||
assert p.part.scale(IN).volume * densa / LB == pytest.approx(3.92, 0.03)
|
assert p.part.scale(IN).volume * densa / LB == pytest.approx(3.92, 0.03)
|
||||||
|
|
||||||
benchmark(model)
|
benchmark(model)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("test_input", [100, 1000, 10000, 100000])
|
||||||
|
def test_mesher_benchmark(benchmark, test_input):
|
||||||
|
# in the 100_000 case test should take on the order of 0.2 seconds
|
||||||
|
# but usually less than 1 second
|
||||||
|
def test_create_3mf_mesh(i):
|
||||||
|
vertices = [(float(i), 0.0, 0.0) for i in range(i)]
|
||||||
|
triangles = [[i, i + 1, i + 2] for i in range(0, i - 3, 3)]
|
||||||
|
mesher = Mesher()._create_3mf_mesh(vertices, triangles)
|
||||||
|
assert len(mesher[0]) == i
|
||||||
|
assert len(mesher[1]) == int(i / 3)
|
||||||
|
|
||||||
|
benchmark(test_create_3mf_mesh, test_input)
|
||||||
|
|
|
||||||
|
|
@ -17,19 +17,6 @@ from build123d.topology import Compound, Solid
|
||||||
from build123d.geometry import Axis, Color, Location, Vector, VectorLike
|
from build123d.geometry import Axis, Color, Location, Vector, VectorLike
|
||||||
from build123d.mesher import Mesher
|
from build123d.mesher import Mesher
|
||||||
|
|
||||||
class InternalApiBenchmark(unittest.TestCase):
|
|
||||||
def test_create_3mf_mesh(self):
|
|
||||||
start = time.perf_counter()
|
|
||||||
for i in [100, 1000, 10000, 100000]:
|
|
||||||
vertices = [(float(i), 0.0, 0.0) for i in range(i)]
|
|
||||||
triangles = [[i, i+1, i+2] for i in range(0, i-3, 3)]
|
|
||||||
start = time.perf_counter()
|
|
||||||
Mesher()._create_3mf_mesh(vertices, triangles)
|
|
||||||
runtime = time.perf_counter() - start
|
|
||||||
print(f"| {i} | {runtime:.3f} |")
|
|
||||||
final_runtime = time.perf_counter() - start
|
|
||||||
max_runtime = 1.0
|
|
||||||
self.assertLessEqual(final_runtime, max_runtime, f"All meshes took {final_runtime:.3f}s > {max_runtime}s")
|
|
||||||
|
|
||||||
class DirectApiTestCase(unittest.TestCase):
|
class DirectApiTestCase(unittest.TestCase):
|
||||||
def assertTupleAlmostEquals(
|
def assertTupleAlmostEquals(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue