Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions appstats_logger/recorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import threading
import time

from google.appengine.api import runtime


class Recorder(object):
"""In-memory state for the current request.
Expand Down Expand Up @@ -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.

Expand Down Expand Up @@ -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
}