Skip to content

Commit

Permalink
Profiler - Function time profiler
Browse files Browse the repository at this point in the history
  • Loading branch information
Alphagon committed Oct 1, 2024
1 parent 37107b1 commit 974a5a2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion nbs/profiler.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"metadata": {},
"outputs": [],
"source": [
"# | default_exp misc"
"# | default_exp profiler"
]
},
{
Expand Down
10 changes: 8 additions & 2 deletions torch_snippets/profiler.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
# AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/profiler.ipynb.

# %% auto 0
__all__ = ['time_profiler']

# %% ../nbs/profiler.ipynb 2
import cProfile
import pstats
from io import StringIO


# %% ../nbs/profiler.ipynb 3
def time_profiler(filename='profiling_results.txt'):
# The outer function that allows customization of the filename
def decorator(func):
Expand All @@ -22,4 +28,4 @@ def wrapper(*args, **kwargs):
f.write(s.getvalue())
return result
return wrapper
return decorator
return decorator

0 comments on commit 974a5a2

Please sign in to comment.