Skip to content

Commit 3c41f6b

Browse files
committed
IfcOpenShell#1153 draw.py timing
1 parent a17c44c commit 3c41f6b

File tree

1 file changed

+22
-3
lines changed
  • src/ifcopenshell-python/ifcopenshell

1 file changed

+22
-3
lines changed

src/ifcopenshell-python/ifcopenshell/draw.py

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,20 @@ def pythonize(arr):
312312

313313
if __name__ == "__main__":
314314
import sys
315+
import time
315316
import argparse
317+
318+
times = []
319+
320+
def measure(task, fn):
321+
t0 = time.time()
322+
r = fn()
323+
dt = time.time() - t0
324+
times.append((task, dt))
325+
return r
326+
327+
def print_progress(*args):
328+
print("\r", *args, " "*10, end="", flush=True)
316329

317330
parser = argparse.ArgumentParser()
318331

@@ -339,6 +352,12 @@ def pythonize(arr):
339352

340353
settings = draw_settings(**args)
341354

342-
files = list(map(ifcopenshell.open, files))
343-
open(output, "wb").write(main(settings, files, progress_function=lambda *args: print("\r", *args, " "*10, end="", flush=True)))
344-
print("\r Done!", " " * 10)
355+
files = measure("open files", lambda: list(map(ifcopenshell.open, files)))
356+
result = measure("processing", lambda: main(settings, files, progress_function=print_progress))
357+
open(output, "wb").write(result)
358+
359+
print("\r Done!", " " * 20)
360+
361+
for t, dt in times:
362+
print(f"{t}: {dt}")
363+

0 commit comments

Comments
 (0)