"git@developer.sourcefind.cn:OpenDAS/lmdeploy.git" did not exist on "c261b49d5a4db2cdd26738e3df209e5a9068a479"
Commit 94fc862f authored by Patrick Labatut's avatar Patrick Labatut Committed by Facebook GitHub Bot
Browse files

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
parent 797e468e
...@@ -605,19 +605,11 @@ class TestMeshObjIO(TestCaseMixin, unittest.TestCase): ...@@ -605,19 +605,11 @@ class TestMeshObjIO(TestCaseMixin, unittest.TestCase):
def bm_save_simple_obj_with_init(V: int, F: int): 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) 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) faces_list = torch.tensor(F * [[1, 2, 3]]).view(-1, 3)
obj_file = StringIO() return lambda: save_obj(
StringIO(), verts_list, faces_list, decimal_places=2
def save_mesh(): )
save_obj(obj_file, verts_list, faces_list, decimal_places=2)
return save_mesh
@staticmethod @staticmethod
def bm_load_simple_obj_with_init(V: int, F: int): 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) obj = "\n".join(["v 0.1 0.2 0.3"] * V + ["f 1 2 3"] * F)
return lambda: load_obj(StringIO(obj))
def load_mesh():
obj_file = StringIO(obj)
verts, faces, aux = load_obj(obj_file)
return load_mesh
...@@ -410,12 +410,9 @@ class TestMeshPlyIO(TestCaseMixin, unittest.TestCase): ...@@ -410,12 +410,9 @@ class TestMeshPlyIO(TestCaseMixin, unittest.TestCase):
def bm_save_simple_ply_with_init(V: int, F: int): 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) 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) faces_list = torch.tensor(F * [[0, 1, 2]]).view(-1, 3)
return lambda: save_ply(
def save_mesh(): StringIO(), verts_list, faces_list, decimal_places=2
file = StringIO() )
save_ply(file, verts_list, faces_list, 2)
return save_mesh
@staticmethod @staticmethod
def bm_load_simple_ply_with_init(V: int, F: int): def bm_load_simple_ply_with_init(V: int, F: int):
...@@ -425,9 +422,4 @@ class TestMeshPlyIO(TestCaseMixin, unittest.TestCase): ...@@ -425,9 +422,4 @@ class TestMeshPlyIO(TestCaseMixin, unittest.TestCase):
save_ply(ply_file, verts=verts, faces=faces) save_ply(ply_file, verts=verts, faces=faces)
ply = ply_file.getvalue() ply = ply_file.getvalue()
# Recreate stream so it's unaffected by how it was created. # Recreate stream so it's unaffected by how it was created.
return lambda: load_ply(StringIO(ply))
def load_mesh():
ply_file = StringIO(ply)
verts, faces = load_ply(ply_file)
return load_mesh
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment