1
0
mirror of https://github.com/openSUSE/osc.git synced 2024-11-10 06:46:15 +01:00
github.com_openSUSE_osc/osc_hotshot.py

33 lines
628 B
Python
Raw Normal View History

#!/usr/bin/env python
import hotshot, hotshot.stats
import tempfile
import os, sys
from osc import commandline
if __name__ == '__main__':
(fd, filename) = tempfile.mkstemp(prefix = 'osc_profiledata_', dir = '/dev/shm')
f = os.fdopen(fd)
try:
prof = hotshot.Profile(filename)
2009-10-20 16:30:15 +02:00
prof.runcall(commandline.main)
print 'run complete. analyzing.'
prof.close()
stats = hotshot.stats.load(filename)
stats.strip_dirs()
stats.sort_stats('time', 'calls')
stats.print_stats(20)
del stats
finally:
f.close()
os.unlink(filename)