Skip to content

yuriiz/spyprof

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SPyProf

Sampling line-by-line Python profiler.

Installation

pip install https://github.com/yuriiz/spyprof

Usage

Import spyprof module at startup:

import spyprof

Profiling reports will be written to spyprof directory periodically every 10 seconds and at application exit.

Profiling report measured with ITIMER_REAL timer will be written to spyprof/real.html.

Profiling report measured with ITIMER_PROF timer will be written to spyprof/prof.html.

Example

Running following code:

import math
from time import sleep

import spyprof


def foo():
    """
    CPU time consuming code.
    """
    for i in range(10**8):
        math.sqrt(i)
        math.sqrt(i)
        pass


def bar():
    """
    Real time consuming code.
    """
    sleep(10)


if __name__ == "__main__":
    foo()
    bar()

Will result in the following reports:

real.html prof.html
Screenshot 2025-09-08 at 21-38-40 Screenshot 2025-09-08 at 21-38-34

About

Sampling Python profiler

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

Languages