Created
September 15, 2015 22:50
-
-
Save kwlzn/42b809558dc825821ddb to your computer and use it in GitHub Desktop.
yappi profiling
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import atexit, yappi | |
def init_yappi(): | |
print('[YAPPI START]') | |
yappi.set_clock_type('wall') | |
yappi.start() | |
@atexit.register | |
def finish_yappi(): | |
print('[YAPPI STOP]') | |
yappi.stop() | |
print('[YAPPI WRITE]') | |
stats = yappi.get_func_stats() | |
for stat_type in ['pstat', 'callgrind', 'ystat']: | |
print('writing /tmp/pants.{}'.format(stat_type)) | |
stats.save('/tmp/pants.{}'.format(stat_type), type=stat_type) | |
print('\n[YAPPI FUNC_STATS]') | |
print('writing /tmp/pants.func_stats') | |
with open('/tmp/pants.func_stats', 'wb') as fh: | |
stats.print_all(out=fh) | |
print('\n[YAPPI THREAD_STATS]') | |
print('writing /tmp/pants.thread_stats') | |
tstats = yappi.get_thread_stats() | |
with open('/tmp/pants.thread_stats', 'wb') as fh: | |
tstats.print_all(out=fh) | |
print('[YAPPI OUT]') | |
... | |
if __name__ == '__main__': | |
init_yappi() | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment