Commit f65762d8 authored by Vincent Pelletier's avatar Vincent Pelletier

More profiling decorators.

git-svn-id: https://svn.erp5.org/repos/neo/trunk@2008 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 0d2d90f3
...@@ -1015,6 +1015,7 @@ class Application(object): ...@@ -1015,6 +1015,7 @@ class Application(object):
return history_list return history_list
@profiler_decorator
def importFrom(self, source, start, stop, tryToResolveConflict): def importFrom(self, source, start, stop, tryToResolveConflict):
serials = {} serials = {}
def updateLastSerial(oid, result): def updateLastSerial(oid, result):
......
...@@ -86,6 +86,7 @@ class HandlerSwitcher(object): ...@@ -86,6 +86,7 @@ class HandlerSwitcher(object):
def getHandler(self): def getHandler(self):
return self._pending[0][1] return self._pending[0][1]
@profiler_decorator
def emit(self, request): def emit(self, request):
# register the request in the current handler # register the request in the current handler
_pending = self._pending _pending = self._pending
...@@ -97,6 +98,7 @@ class HandlerSwitcher(object): ...@@ -97,6 +98,7 @@ class HandlerSwitcher(object):
assert msg_id not in request_dict, "Packet id already expected" assert msg_id not in request_dict, "Packet id already expected"
request_dict[msg_id] = answer_class request_dict[msg_id] = answer_class
@profiler_decorator
def handle(self, packet): def handle(self, packet):
assert len(self._pending) == 1 or self._pending[0][0] assert len(self._pending) == 1 or self._pending[0][0]
PACKET_LOGGER.dispatch(self._connection, packet, 'from') PACKET_LOGGER.dispatch(self._connection, packet, 'from')
...@@ -121,6 +123,7 @@ class HandlerSwitcher(object): ...@@ -121,6 +123,7 @@ class HandlerSwitcher(object):
del self._pending[0] del self._pending[0]
logging.debug('Apply handler %r', self._pending[0][1]) logging.debug('Apply handler %r', self._pending[0][1])
@profiler_decorator
def setHandler(self, handler): def setHandler(self, handler):
if len(self._pending) == 1 and not self._pending[0][0]: if len(self._pending) == 1 and not self._pending[0][0]:
# nothing is pending, change immediately # nothing is pending, change immediately
...@@ -601,6 +604,7 @@ class MTClientConnection(ClientConnection): ...@@ -601,6 +604,7 @@ class MTClientConnection(ClientConnection):
finally: finally:
self.unlock() self.unlock()
@profiler_decorator
def ask(self, packet, timeout=CRITICAL_TIMEOUT): def ask(self, packet, timeout=CRITICAL_TIMEOUT):
self.lock() self.lock()
try: try:
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
from time import time from time import time
from neo.epoll import Epoll from neo.epoll import Epoll
from neo.profiling import profiler_decorator
class EpollEventManager(object): class EpollEventManager(object):
"""This class manages connections and events based on epoll(5).""" """This class manages connections and events based on epoll(5)."""
...@@ -173,6 +174,7 @@ class EpollEventManager(object): ...@@ -173,6 +174,7 @@ class EpollEventManager(object):
self.reader_set.remove(fd) self.reader_set.remove(fd)
self.epoll.modify(fd, 0, fd in self.writer_set) self.epoll.modify(fd, 0, fd in self.writer_set)
@profiler_decorator
def addWriter(self, conn): def addWriter(self, conn):
connector = conn.getConnector() connector = conn.getConnector()
assert connector is not None, conn.whoSetConnector() assert connector is not None, conn.whoSetConnector()
......
...@@ -209,6 +209,7 @@ def _decodeString(buf, name, offset=0): ...@@ -209,6 +209,7 @@ def _decodeString(buf, name, offset=0):
raise PacketMalformedError("can't read string <%s>" % name) raise PacketMalformedError("can't read string <%s>" % name)
return (string, buf[offset+4+size:]) return (string, buf[offset+4+size:])
@profiler_decorator
def _encodeString(buf): def _encodeString(buf):
return pack('!L', len(buf)) + buf return pack('!L', len(buf)) + buf
...@@ -272,6 +273,7 @@ class Packet(object): ...@@ -272,6 +273,7 @@ class Packet(object):
return (pack(PACKET_HEADER_FORMAT, self._id, self._code, length), return (pack(PACKET_HEADER_FORMAT, self._id, self._code, length),
content) content)
@profiler_decorator
def __len__(self): def __len__(self):
return PACKET_HEADER_SIZE + len(self._body) return PACKET_HEADER_SIZE + len(self._body)
...@@ -881,6 +883,7 @@ class AskStoreObject(Packet): ...@@ -881,6 +883,7 @@ class AskStoreObject(Packet):
""" """
_header_format = '!8s8s8sBL' _header_format = '!8s8s8sBL'
@profiler_decorator
def _encode(self, oid, serial, compression, checksum, data, tid): def _encode(self, oid, serial, compression, checksum, data, tid):
if serial is None: if serial is None:
serial = INVALID_TID serial = INVALID_TID
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment