mirror of
https://github.com/facebookresearch/pytorch3d.git
synced 2025-08-02 03:42:50 +08:00
Simplify mesh I/O benchmarking methods
Summary: Rename mesh I/O benchmarking methods: always (re-)create file-like object and directly return a lambda Reviewed By: nikhilaravi Differential Revision: D20390723 fbshipit-source-id: b45236360869cccdf3d5458a0aafb3ebe269babe
This commit is contained in:
parent
797e468e45
commit
94fc862ff7
@ -605,19 +605,11 @@ class TestMeshObjIO(TestCaseMixin, unittest.TestCase):
|
||||
def bm_save_simple_obj_with_init(V: int, F: int):
|
||||
verts_list = torch.tensor(V * [[0.11, 0.22, 0.33]]).view(-1, 3)
|
||||
faces_list = torch.tensor(F * [[1, 2, 3]]).view(-1, 3)
|
||||
obj_file = StringIO()
|
||||
|
||||
def save_mesh():
|
||||
save_obj(obj_file, verts_list, faces_list, decimal_places=2)
|
||||
|
||||
return save_mesh
|
||||
return lambda: save_obj(
|
||||
StringIO(), verts_list, faces_list, decimal_places=2
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def bm_load_simple_obj_with_init(V: int, F: int):
|
||||
obj = "\n".join(["v 0.1 0.2 0.3"] * V + ["f 1 2 3"] * F)
|
||||
|
||||
def load_mesh():
|
||||
obj_file = StringIO(obj)
|
||||
verts, faces, aux = load_obj(obj_file)
|
||||
|
||||
return load_mesh
|
||||
return lambda: load_obj(StringIO(obj))
|
||||
|
@ -410,12 +410,9 @@ class TestMeshPlyIO(TestCaseMixin, unittest.TestCase):
|
||||
def bm_save_simple_ply_with_init(V: int, F: int):
|
||||
verts_list = torch.tensor(V * [[0.11, 0.22, 0.33]]).view(-1, 3)
|
||||
faces_list = torch.tensor(F * [[0, 1, 2]]).view(-1, 3)
|
||||
|
||||
def save_mesh():
|
||||
file = StringIO()
|
||||
save_ply(file, verts_list, faces_list, 2)
|
||||
|
||||
return save_mesh
|
||||
return lambda: save_ply(
|
||||
StringIO(), verts_list, faces_list, decimal_places=2
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def bm_load_simple_ply_with_init(V: int, F: int):
|
||||
@ -425,9 +422,4 @@ class TestMeshPlyIO(TestCaseMixin, unittest.TestCase):
|
||||
save_ply(ply_file, verts=verts, faces=faces)
|
||||
ply = ply_file.getvalue()
|
||||
# Recreate stream so it's unaffected by how it was created.
|
||||
|
||||
def load_mesh():
|
||||
ply_file = StringIO(ply)
|
||||
verts, faces = load_ply(ply_file)
|
||||
|
||||
return load_mesh
|
||||
return lambda: load_ply(StringIO(ply))
|
||||
|
Loading…
x
Reference in New Issue
Block a user