From 6ee8dd10dbc7e97ee29e05dcd922ce5070a371f8 Mon Sep 17 00:00:00 2001 From: Bruno Wagner Date: Thu, 25 Aug 2016 18:50:39 -0300 Subject: Adapted the twisted patch to measure inlineCallbacks #768 We did two changes to the twisted patch to be able to measure the inlineCallbacks correctly: - Filtered the traditional callbacks timing so that it doesn't print inlineCallback timings - Added a measurement for the g.send() method inside the inlineCallback, to measure the actual execution time of the call on the main thread, between the inlineCallback yields --- service/test/reactor/defer.patch | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'service/test/reactor') diff --git a/service/test/reactor/defer.patch b/service/test/reactor/defer.patch index de2f7d82..296112f4 100644 --- a/service/test/reactor/defer.patch +++ b/service/test/reactor/defer.patch @@ -6,11 +6,11 @@ > self.start = datetime.now() > self.label = label > -> def stop(self): +> def stop(self, callback_type): > end = datetime.now() > total = (end - self.start).total_seconds() > if total > 0.1: -> print('EXECUTING {} {:.5f}'.format(self.label, total)) +> print('EXECUTING {}: {} {:.5f}'.format(callback_type, self.label, total)) > 195c208,221 < @@ -25,23 +25,27 @@ > return str(i) > else: > if 'gotResult' == i.__name__: -> return str(i.__closure__[1].cell_contents) +> return False > f = inspect.getsourcefile(i) > ln = inspect.getsourcelines(i)[1] > return "%s (%s:%d)" % (str(i), f, ln) -300a327,329 -> -> # print "addCallbacks(%s, %s)" % (identifyItem(callback), identifyItem(errback)) -> -588c617,625 +588c614,624 < current.result = callback(current.result, *args, **kw) --- > currentItem = identifyItem(callback) > currentThreadId = threading.current_thread().ident > -> clock = Clock("%s in thread %d" % (currentItem, currentThreadId)) +> if currentItem: +> clock = Clock("%s in thread %d" % (currentItem, currentThreadId)) > try: > current.result = callback(current.result, *args, **kw) > finally: -> clock.stop() +> if currentItem: +> clock.stop('deferred') > +1123a1160,1161 +> currentThreadId = threading.current_thread().ident +> c = Clock("%s in thread %d" % (str(g.gi_code), currentThreadId)) +1175a1214,1215 +> finally: +> c.stop('inlineCallback') -- cgit v1.2.3