diff --git a/synapse/app/homeserver.py b/synapse/app/homeserver.py index 008fd683bc..a8e1a94dcb 100755 --- a/synapse/app/homeserver.py +++ b/synapse/app/homeserver.py @@ -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) diff --git a/synapse/handlers/room.py b/synapse/handlers/room.py index bd1c20cb13..a86908695d 100644 --- a/synapse/handlers/room.py +++ b/synapse/handlers/room.py @@ -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)