Tiny Profiler is a sub 200 line profiling utility that records telemetry from your app, provides metrics and a flame graph to help debug latency and throughput.
No dependencies!
pip install tinyprofiler
from tinyprofiler import Observer
observer = Observer()
@observer.profile(parent=True)
def your_function():
sub_function1()
sub_function2()
@observer.profile()
def sub_function1():
pass
@observer.profile()
def sub_function2():
pass
Observer(num_samples: int = 10, enabled: bool = True)
-
num_samples
(optional): The number of samples to collect. You can configure how many samples to collect during profiling. The default is 10. -
enabled
(optional): You can enable or disable profiling using this parameter. By default, profiling is enabled (True).
profile(self, trace: str = '__main__', parent: bool = False) -> None:
-
trace
(optional) - the trace to group functions together -
parent
(optional): Set this to True if you want to treat the decorated function as a parent node in the flame graph hierarchy.