From 3a714115270cdf095e7857332b25f237d9b1194f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Manr=C3=ADquez=20Novoa?= <49853152+chopan050@users.noreply.github.com> Date: Sat, 13 Jul 2024 13:13:14 -0400 Subject: [PATCH] Log execution time of scene rendering in the Manim Checkhealth command (#3855) * Log execution time of scene rendering in the Manim Checkhealth command * Use timeit.timeit instead of time.time for more reliable profiling --- manim/cli/checkhealth/commands.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/manim/cli/checkhealth/commands.py b/manim/cli/checkhealth/commands.py index d6873755f2..228aac00dc 100644 --- a/manim/cli/checkhealth/commands.py +++ b/manim/cli/checkhealth/commands.py @@ -6,11 +6,12 @@ from __future__ import annotations import sys +import timeit import click import cloup -from .checks import HEALTH_CHECKS +from manim.cli.checkhealth.checks import HEALTH_CHECKS __all__ = ["checkhealth"] @@ -62,7 +63,7 @@ def checkhealth(): import manim as mn class CheckHealthDemo(mn.Scene): - def construct(self): + def _inner_construct(self): banner = mn.ManimBanner().shift(mn.UP * 0.5) self.play(banner.create()) self.wait(0.5) @@ -79,5 +80,11 @@ def construct(self): mn.FadeOut(text_tex_group, shift=mn.DOWN), ) + def construct(self): + self.execution_time = timeit.timeit(self._inner_construct, number=1) + 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.")