profile performance

In python cli

... python -m cProfile -o stats ...

In iPython

%%prun -r returns profiling object

%%prun -D stats

from oneview.models.helpers.imports import pull_accounts_no_threaded
pull_accounts_no_threaded()

Read Output from profiler

import pstats
# read profile output from a file called `stats`
stats = pstats.Stats('stats')

# starts with Cumulative time to get a sense of the time taken,
# try to spot unexpected time spent and large number of function calls
stats.sort_stats('cumtime').print_stats(100)

# `tottime` for the total time spent in the given function (and excluding time
# made in calls to sub-functions)
stats.sort_stats('tottime').print_stats(100)

stats.sort_stats('filename').print_stats(100)

Alternatively, Just timeit once

%%timeit -n 1 -r 1

from oneview.models.helpers.imports import pull_accounts, pull_accounts_no_threaded
pull_accounts()

See also - pstat sort keys - %prun documentation - %timeit documentation