Created
May 13, 2024 08:45
-
-
Save jonathan-s/d8b4a0a1dff6de7dd0af57f2c1c005a1 to your computer and use it in GitHub Desktop.
Revisions
-
jonathan-s created this gist
May 13, 2024 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,18 @@ from pathlib import Path import cProfile class Profile: def __init__(self, path: Path): self.profiler = None self.path = path def __enter__(self): self.profiler = cProfile.Profile() self.profiler.enable() return self def __exit__(self, *args, **kwargs): self.profiler.dump_stats(self.path) self.profiler = None