Browse Source

Add a few more profiling helpers.

Especially useful is the log print before converting the mesh verticies.
This is the slowest part of Korman, per profiling.
pull/268/head
Adam Johnson 3 years ago
parent
commit
6f83192909
Signed by: Hoikas
GPG Key ID: 0B6515D6FF6F271E
  1. 2
      korman/exporter/mesh.py
  2. 25
      korman/operators/op_lightmap.py

2
korman/exporter/mesh.py

@ -374,6 +374,8 @@ class MeshConverter(_MeshManager):
inc_progress()
def _export_geometry(self, bo, mesh, materials, geospans, mat2span_LUT):
self._report.msg("Converting geometry from '{}'...", mesh.name, indent=1)
# Recall that materials is a mapping of exported materials to blender material indices.
# Therefore, geodata maps blender material indices to working geometry data.
# Maybe the logic is a bit inverted, but it keeps the inner loop simple.

25
korman/operators/op_lightmap.py

@ -16,10 +16,12 @@
import bpy
from bpy.props import *
import cProfile
from contextlib import contextmanager
import itertools
import pstats
from ..exporter.etlight import LightBaker
from ..exporter.explosions import ExportError
from ..helpers import UiHelper
from ..korlib import ConsoleToggler
@ -95,6 +97,25 @@ class LightmapBakeMultiOperator(_LightingOperator, bpy.types.Operator):
super().__init__()
def execute(self, context):
profile_me = False
try:
if profile_me:
cProfile.runctx("self._run(context)", globals(), locals(), "bake_cProfile")
else:
self._run(context)
except ExportError as error:
self.report({"ERROR"}, str(error))
return {"CANCELLED"}
else:
if profile_me:
with open("bake_profile.log", "w") as out:
stats = pstats.Stats("bake_cProfile", stream=out)
stats = stats.sort_stats("time", "cumtime")
stats.print_stats()
return {"FINISHED"}
def _run(self, context):
all_objects = context.selected_objects if self.bake_selection else context.scene.objects
filtered_objects = [i for i in all_objects if i.type == "MESH" and i.plasma_object.enabled]
@ -109,8 +130,6 @@ class LightmapBakeMultiOperator(_LightingOperator, bpy.types.Operator):
if lightmap_mod.bake_lightmap:
lightmap_mod.image = bake.get_lightmap(i)
return {"FINISHED"}
class LightmapClearMultiOperator(_LightingOperator, bpy.types.Operator):
bl_idname = "object.plasma_lightmap_clear"

Loading…
Cancel
Save