In Google App Engine, how can I check my CPU usage before and after running a collection of tasks?
In Google App Engine, how do you check to see how much CPU has been used before and after a collection of events? I understand how to check the CPU usage during a single url fetch and I understand how to use stats to look at sp开发者_Python百科ecific events in aggregate, but how can I determine how much CPU was used between say 5:00pm and 5:15pm?
Is there a way to query for my daily usage and then query it again 10-15 minutes later? I can screen scrape this from appspot if necessary, but this seems very inefficient.
Unfortunately, there is no API for querying that sort of data.
Dashboard. It will probably be difficult to get an accurate measurement by screen scraping the dashboard. There is a delay between a request executing and quota utilization showing up (on the dashboard or quotas page). If you have no other requests to your app, then I guess this is okay - just read the counters before your job, and then read them again a little after your job has completed.
AppStats. Alternatively, you could use AppStats. You can download the main AppStats page throughout the set of events you're interested in measuring, and then sum the usages reported for each of the individual requests.
You can check the instance cpu and memory usage with the runtime API
runtime.cpu_usage().total() gives you the total Mcycles consumed by this instance.
https://developers.google.com/appengine/docs/python/backends/runtimeapi
精彩评论