[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[IMP-dev] sample profiling output + sample profiling of python script



1) Some people are getting weird results from gperftools/pperf (and I'm happy to help unweird them :). I attach profiling.pdf, a sample output of gperftools so you know how it should look like when it works, in this case for a python IMP script that spends most of its time in the C++ section of the code. You will see 60% of the running time is spent in BrownianDynamics::do_step, of these 45% in score evaluation, of which 16% are spent preparing for score evaluation, 22% in the score evaluation itself, and 6% in post-evaluation tasks. Another 33% are spent in updating optimizer states (in this particular example, which is optimizer state intensive).

2) If most of your running time is not in the C++ parts of the code, you could profile the python code itself. There are many tools available. One easy option to profile a python script at the function level is cProfile (documentation https://docs.python.org/2/library/profile.html). If you just want to quickly start, here is a sample file that uses cProfile. There are other profilers that work for line-by-line profiling of python scripts, or for parallel runs

import cProfile


def ho():

    for i in range(10):

        pass


def hi():

    for i in range(1000):

        ho()


def he():

    for i in range(10000):

        hi()


if __name__ == '__main__':

    cProfile.run('he()')




Attachment: profiling.pdf
Description: Adobe PDF document