Guest User

Untitled

a guest
Sep 15th, 2015
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.90 KB | None | 0 0
  1. import atexit, yappi
  2.  
  3. def init_yappi():
  4.   print('[YAPPI START]')
  5.   yappi.set_clock_type('wall')
  6.   yappi.start()
  7.  
  8.   @atexit.register
  9.   def finish_yappi():
  10.     print('[YAPPI STOP]')
  11.     yappi.stop()
  12.  
  13.     print('[YAPPI WRITE]')
  14.     stats = yappi.get_func_stats()
  15.     for stat_type in ['pstat', 'callgrind', 'ystat']:
  16.       print('writing /tmp/pants.{}'.format(stat_type))
  17.       stats.save('/tmp/pants.{}'.format(stat_type), type=stat_type)
  18.  
  19.     print('\n[YAPPI FUNC_STATS]')
  20.     print('writing /tmp/pants.func_stats')
  21.     with open('/tmp/pants.func_stats', 'wb') as fh:
  22.       stats.print_all(out=fh)
  23.  
  24.     print('\n[YAPPI THREAD_STATS]')
  25.     print('writing /tmp/pants.thread_stats')
  26.     tstats = yappi.get_thread_stats()
  27.     with open('/tmp/pants.thread_stats', 'wb') as fh:
  28.       tstats.print_all(out=fh)
  29.  
  30.     print('[YAPPI OUT]')
  31.  
  32. ...
  33.  
  34. if __name__ == '__main__':
  35.   init_yappi()
  36.   main()
Advertisement
Add Comment
Please, Sign In to add comment