Skip to content

Commit 3a71411

Browse files
authored
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
1 parent 1df1709 commit 3a71411

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

manim/cli/checkhealth/commands.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@
66
from __future__ import annotations
77

88
import sys
9+
import timeit
910

1011
import click
1112
import cloup
1213

13-
from .checks import HEALTH_CHECKS
14+
from manim.cli.checkhealth.checks import HEALTH_CHECKS
1415

1516
__all__ = ["checkhealth"]
1617

@@ -62,7 +63,7 @@ def checkhealth():
6263
import manim as mn
6364

6465
class CheckHealthDemo(mn.Scene):
65-
def construct(self):
66+
def _inner_construct(self):
6667
banner = mn.ManimBanner().shift(mn.UP * 0.5)
6768
self.play(banner.create())
6869
self.wait(0.5)
@@ -79,5 +80,11 @@ def construct(self):
7980
mn.FadeOut(text_tex_group, shift=mn.DOWN),
8081
)
8182

83+
def construct(self):
84+
self.execution_time = timeit.timeit(self._inner_construct, number=1)
85+
8286
with mn.tempconfig({"preview": True, "disable_caching": True}):
83-
CheckHealthDemo().render()
87+
scene = CheckHealthDemo()
88+
scene.render()
89+
90+
click.echo(f"Scene rendered in {scene.execution_time:.2f} seconds.")

0 commit comments

Comments
 (0)