Profiling

import cProfile
import pstats
with cProfile.Profile() as pr:
    yourfunctionhere()
stats = pstats.Stats(pr)
stats.sort_stats(pstats.SortKey.TIME)
stats.print_stats()