Profiling Twisted Applications

    Often I forget how to profile Twisted applications easily and quickly (with some changes it will be suitable for any Python applications). In addition to Twisted, we will also need KCachegrind .

    We launch our application with profiling enabled:
    twistd -n --savestats --profile=myprog.hotshot myprog
    

    We apply the load, the profile is going. Now, using the utility hotshot2cgfrom the KCachegrind delivery, we turn the hotshot profile into a calltree profile, which KCachegrind already knows how to “eat”.
    hotshot2cg myprog.hotshot > myprog.calltree
    

    We start KCachegrind, open the received profile in it:
    kcachegrind myprog.calltree
    

    Also popular now: