使用Python监控App Engine中的CPU使用情况
有没有办法在Python中获取应用引擎当前的CPU配额?(就是管理员控制台仪表板上显示的CPU时间的数值)
提前谢谢!
1 个回答
2
http://code.google.com/p/googleappengine/source/browse/trunk/python/google/appengine/api/quota.py
如果那个类有限制的话,可以尝试用反复试验或者Jython(速度比较慢)。
不过它看起来能满足你的需求:
import logging
from google.appengine.api import quota
start = quota.get_request_cpu_usage()
do_something_expensive()
end = quota.get_request_cpu_usage()
logging.info("do_something_expensive() cost %d megacycles." % (end - start))
新的独立Python部分在http://code.google.com/appengine/docs/quotas.html上似乎还没有完成。