Performance testing of OBJ loaderΒΆ

[1]:
%load_ext autoreload
%autoreload 2
[2]:
import os
import imageio
import pandas as pd
import numpy as np
import timeit
import lmfunctest as ft
import lmscene
import lightmetrica as lm
[3]:
%load_ext lightmetrica_jupyter
[4]:
lm.init('user::default', {})
lm.parallel.init('parallel::openmp', {
    'numThreads': -1
})
lm.log.init('logger::jupyter', {})
lm.info()
[I|0.000|114@user  ] Lightmetrica -- Version 3.0.0 (rev. fe30e7c) Linux x64
[5]:
lm.comp.loadPlugin(os.path.join(ft.env.bin_path, 'objloader_tinyobjloader'))
[I|0.020|179@compon] Loading plugin [name='objloader_tinyobjloader']
[I|0.020|197@compon]   Successfully loaded
[5]:
True
[6]:
objloaders = ['objloader::simple', 'objloader::tinyobjloader']
scenes = lmscene.scenes_small()
[7]:
loading_time_df = pd.DataFrame(columns=objloaders, index=scenes)
for scene in scenes:
    # Check consistency with other loaders
    for objloader in objloaders:
        # Load the scene with selected obj loader
        lm.objloader.init(objloader, {})
        lm.reset()
        def load_scene():
            lmscene.load(ft.env.scene_path, scene)
        loading_time = timeit.timeit(stmt=load_scene, number=1)
        loading_time_df[objloader][scene] = loading_time
[I|0.068|48@assets ] Loading asset [name='camera_main']
[I|0.068|48@assets ] Loading asset [name='model_obj']
[I|0.068|29@objload]   Loading OBJ file [path='fireplace_room.obj']
[I|0.068|169@objloa]   Loading MTL file [path='fireplace_room.mtl']
[I|0.068|44@texture]   Loading texture [path='wood.ppm']
[I|0.174|44@texture]   Loading texture [path='leaf.ppm']
[I|0.178|44@texture]   Loading texture [path='picture8.ppm']
[I|0.219|44@texture]   Loading texture [path='wood5.ppm']
[I|0.660|48@assets ] Loading asset [name='camera_main']
[I|0.661|48@assets ] Loading asset [name='model_obj']
[I|0.922|44@texture]   Loading texture [path='wood.ppm']
[I|1.027|44@texture]   Loading texture [path='leaf.ppm']
[I|1.030|44@texture]   Loading texture [path='picture8.ppm']
[I|1.066|44@texture]   Loading texture [path='wood5.ppm']
[I|1.131|48@assets ] Loading asset [name='camera_main']
[I|1.132|48@assets ] Loading asset [name='model_obj']
[I|1.132|29@objload]   Loading OBJ file [path='CornellBox-Sphere.obj']
[I|1.132|169@objloa]   Loading MTL file [path='CornellBox-Sphere.mtl']
[I|1.135|48@assets ] Loading asset [name='camera_main']
[I|1.135|48@assets ] Loading asset [name='model_obj']
[W|1.138|43@objload]   Both `d` and `Tr` parameters defined for "light". Use the value of `d` for dissolve (line 76 in .mtl.)

[I|1.139|48@assets ] Loading asset [name='camera_main']
[I|1.139|48@assets ] Loading asset [name='model_obj']
[I|1.139|29@objload]   Loading OBJ file [path='cube.obj']
[I|1.139|169@objloa]   Loading MTL file [path='default.mtl']
[I|1.139|44@texture]   Loading texture [path='default.png']
[I|1.156|48@assets ] Loading asset [name='camera_main']
[I|1.156|48@assets ] Loading asset [name='model_obj']
[I|1.156|44@texture]   Loading texture [path='default.png']
[8]:
loading_time_df
[8]:
objloader::simple objloader::tinyobjloader
fireplace_room 0.590972 0.468631
cornell_box_sphere 0.00331342 0.00296321
cube 0.0166067 0.0149226