标签:imp test class i/o ring col int profile openstack
方法01:
##利用python的标准库cProfile
##nova/api/openstack/wsgi.py
import time import cProfile, pstats, StringIO from oslo_middleware import request_id pr = cProfile.Profile() pr.enable() start_time = time.time() doSomething() end_time = time.time() pr.disable() s = StringIO.StringIO() sortby = ‘cumulative‘ ps = pstats.Stats(pr, stream=s).sort_stats(sortby) ps.print_stats() req_id = request.environ.get(request_id.ENV_REQUEST_ID) p = open("/tmp/test/" + str(req_id),‘w‘) p.write(s.getvalue()) p.close()
标签:imp test class i/o ring col int profile openstack
原文地址:http://www.cnblogs.com/yaoweilei/p/7549949.html