From 4afc856ff8e9b35f1a28a82f7e1f8e9af85931e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Manr=C3=ADquez?= Date: Sat, 13 Jul 2024 11:14:36 -0400 Subject: [PATCH 1/2] Log execution time of scene rendering in the Manim Checkhealth command --- manim/cli/checkhealth/commands.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/manim/cli/checkhealth/commands.py b/manim/cli/checkhealth/commands.py index d6873755f2..b344e2c129 100644 --- a/manim/cli/checkhealth/commands.py +++ b/manim/cli/checkhealth/commands.py @@ -6,11 +6,12 @@ from __future__ import annotations import sys +import time import click import cloup -from .checks import HEALTH_CHECKS +from manim.cli.checkhealth.checks import HEALTH_CHECKS __all__ = ["checkhealth"] @@ -62,7 +63,13 @@ def checkhealth(): import manim as mn class CheckHealthDemo(mn.Scene): + def __init__(self): + super().__init__() + self.execution_time = None + def construct(self): + start = time.time() + banner = mn.ManimBanner().shift(mn.UP * 0.5) self.play(banner.create()) self.wait(0.5) @@ -79,5 +86,10 @@ def construct(self): mn.FadeOut(text_tex_group, shift=mn.DOWN), ) + self.execution_time = time.time() - start + with mn.tempconfig({"preview": True, "disable_caching": True}): - CheckHealthDemo().render() + scene = CheckHealthDemo() + scene.render() + + click.echo(f"Scene rendered in {scene.execution_time:.2f} seconds.") From 26f37f655ccd03cd4e034fff778543c264bca318 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Manr=C3=ADquez?= Date: Sat, 13 Jul 2024 12:11:49 -0400 Subject: [PATCH 2/2] Use timeit.timeit instead of time.time for more reliable profiling --- manim/cli/checkhealth/commands.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/manim/cli/checkhealth/commands.py b/manim/cli/checkhealth/commands.py index b344e2c129..228aac00dc 100644 --- a/manim/cli/checkhealth/commands.py +++ b/manim/cli/checkhealth/commands.py @@ -6,7 +6,7 @@ from __future__ import annotations import sys -import time +import timeit import click import cloup @@ -63,13 +63,7 @@ def checkhealth(): import manim as mn class CheckHealthDemo(mn.Scene): - def __init__(self): - super().__init__() - self.execution_time = None - - def construct(self): - start = time.time() - + def _inner_construct(self): banner = mn.ManimBanner().shift(mn.UP * 0.5) self.play(banner.create()) self.wait(0.5) @@ -86,7 +80,8 @@ def construct(self): mn.FadeOut(text_tex_group, shift=mn.DOWN), ) - self.execution_time = time.time() - start + def construct(self): + self.execution_time = timeit.timeit(self._inner_construct, number=1) with mn.tempconfig({"preview": True, "disable_caching": True}): scene = CheckHealthDemo()