diff --git a/appstats_logger/recorder.py b/appstats_logger/recorder.py index 4d2dfa3..d9c6f27 100644 --- a/appstats_logger/recorder.py +++ b/appstats_logger/recorder.py @@ -21,6 +21,8 @@ import threading import time +from google.appengine.api import runtime + class Recorder(object): """In-memory state for the current request. @@ -49,6 +51,8 @@ def __init__(self, env): self.overhead = (time.time() - self.start_timestamp) + self.start_memory = runtime.memory_usage().current() + def record_rpc_request(self, service, call, request, response, rpc): """Record the request of an RPC call. @@ -132,9 +136,12 @@ def record_rpc_response(self, service, call, request, response, rpc): def get_profile_data(self): """Return a dict with the profile results.""" + end_memory = runtime.memory_usage().current() return { 'overhead': int(self.overhead * 1000), 'exec_time': int((time.time() - self.start_timestamp) * 1000), + 'memory_delta': float(end_memory - self.start_memory), + 'memory_end': end_memory, 'calls': self.traces }