2006-04-27 15:59:34 +02:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
import hotshot, hotshot.stats
|
|
|
|
import tempfile
|
|
|
|
import os, sys
|
2006-05-31 17:05:37 +02:00
|
|
|
|
|
|
|
from osc import commandline
|
2006-04-27 15:59:34 +02:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
|
2006-07-14 18:38:54 +02:00
|
|
|
(fd, filename) = tempfile.mkstemp(prefix = 'osc_profiledata_', dir = '/dev/shm')
|
|
|
|
f = os.fdopen(fd)
|
2006-04-27 15:59:34 +02:00
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
prof = hotshot.Profile(filename)
|
|
|
|
|
2006-05-31 17:05:37 +02:00
|
|
|
prof.runcall(commandline.main)
|
2006-04-27 15:59:34 +02:00
|
|
|
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:
|
2006-07-14 18:38:54 +02:00
|
|
|
f.close()
|
2006-04-27 15:59:34 +02:00
|
|
|
os.unlink(filename)
|