Skip to content

carterjfulcher/tinyprofiler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tinyprofiler

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!

Installation

pip install tinyprofiler

Usage

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

img

API

Observer

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).

Observer.profile (decorator)

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.