Make class variable

This commit is contained in:
Erik Johnston 2015-06-01 14:06:59 +01:00
parent 06d1ec5dbc
commit a9de1ee4c4
2 changed files with 7 additions and 6 deletions

View file

@ -522,19 +522,20 @@ class SynapseSite(Site):
def run(hs):
def prof(f):
import synapse.handlers.room
from synapse.handlers.room import RoomMemberHandler
import time
def g(*args, **kwargs):
start = int(time.time()*1000)
f(*args, **kwargs)
end = int(time.time()*1000)
if synapse.handlers.room.total_time > 50:
if RoomMemberHandler.total_time > 0:
logger.info(
"Total time in get_room_members: %d ms / %d ms",
int(total_time*1000),
int(RoomMemberHandler.total_time*1000),
end - start
)
synapse.handlers.room.total_time = 0
RoomMemberHandler.total_time = 0
return g
reactor.runUntilCurrent = prof(reactor.runUntilCurrent)

View file

@ -237,7 +237,6 @@ class RoomCreationHandler(BaseHandler):
]
import time
total_time = 0
class RoomMemberHandler(BaseHandler):
# TODO(paul): This handler currently contains a messy conflation of
@ -245,6 +244,8 @@ class RoomMemberHandler(BaseHandler):
# API that takes ID strings and returns pagination chunks. These concerns
# ought to be separated out a lot better.
total_time = 0
def __init__(self, hs):
super(RoomMemberHandler, self).__init__(hs)
@ -262,8 +263,7 @@ class RoomMemberHandler(BaseHandler):
users = [UserID.from_string(u) for u in users]
end = time.time()
global total_time
total_time += end-start
RoomMemberHandler.total_time += end-start
defer.returnValue(users)