From 9630ab9aae29ae7cadcf446849d036cbc9feee23 Mon Sep 17 00:00:00 2001 From: Brian Warner Date: Thu, 3 Mar 2016 15:07:05 -0800 Subject: [PATCH] find-tor: record more detailed timings --- src/wormhole/scripts/cmd_receive_twisted.py | 2 ++ src/wormhole/twisted/tor_manager.py | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/src/wormhole/scripts/cmd_receive_twisted.py b/src/wormhole/scripts/cmd_receive_twisted.py index cb761ba..2f8e38f 100644 --- a/src/wormhole/scripts/cmd_receive_twisted.py +++ b/src/wormhole/scripts/cmd_receive_twisted.py @@ -41,7 +41,9 @@ class TwistedReceiver(BlockingReceiver): def go(self): tor_manager = None if self.args.tor: + _start = self.args.timing.add_event("import TorManager") from ..twisted.tor_manager import TorManager + self.args.timing.finish_event(_start) tor_manager = TorManager(reactor, timing=self.args.timing) # For now, block everything until Tor has started. Soon: launch # tor in parallel with everything else, make sure the TorManager diff --git a/src/wormhole/twisted/tor_manager.py b/src/wormhole/twisted/tor_manager.py index 444bb02..33b8c43 100644 --- a/src/wormhole/twisted/tor_manager.py +++ b/src/wormhole/twisted/tor_manager.py @@ -79,6 +79,7 @@ class TorManager: _start_find = self._timing.add_event("find tor") # try port 9051, then try /var/run/tor/control . Throws on failure. state = None + _start_tcp = self._timing.add_event("tor localhost") try: connection = (self._reactor, "127.0.0.1", self._tor_control_port) state = yield txtorcon.build_tor_connection(connection) @@ -86,8 +87,10 @@ class TorManager: except ConnectError: print("unable to reach Tor on %d" % self._tor_control_port) pass + self._timing.finish_event(_start_tcp) if not state: + _start_unix = self._timing.add_event("tor unix") try: connection = (self._reactor, "/var/run/tor/control") state = yield txtorcon.build_tor_connection(connection) @@ -95,6 +98,7 @@ class TorManager: except (ValueError, ConnectError): print("unable to reach Tor on /var/run/tor/control") pass + self._timing.finish_event(_start_unix) if state: print("connected to pre-existing Tor process")