def print_stats(self): if self._started: self._total += self._cnt stopped = rtime() cps = float(self._cnt) / float(stopped - self._started) print("{} calls/s ({} succeeded)".format(cps, self._total)) self._started = rtime() self._cnt = 0
def trigger_gc(self, details=None): """ Manually trigger a garbage collection in this native process. This procedure is registered under ``crossbar.node.<node_id>.worker.<worker_id>.trigger_gc`` for native workers and under ``crossbar.node.<node_id>.controller.trigger_gc`` for node controllers. The procedure will publish an event when the garabage collection has finished to ``crossbar.node.<node_id>.worker.<worker_id>.on_gc_finished`` for native workers and ``crossbar.node.<node_id>.controller.on_gc_finished`` for node controllers: .. code-block:: javascript { "requester": { "session_id": 982734923, "auth_id": "bob", "auth_role": "admin" }, "duration": 190 } .. note:: The caller of this procedure will NOT receive the event. :returns: Time (wall clock) consumed for garbage collection in ms. :rtype: int """ self.log.debug("{cls}.trigger_gc", cls=self.__class__.__name__) started = rtime() # now trigger GC .. this is blocking! gc.collect() duration = int(round(1000. * (rtime() - started))) on_gc_finished = u'{}.on_gc_finished'.format(self._uri_prefix) self.publish( on_gc_finished, { u'requester': { u'session_id': details.caller, # FIXME: u'auth_id': None, u'auth_role': None }, u'duration': duration }, options=PublishOptions(exclude=details.caller) ) return duration
def print_stats(self): if self._started: self._total += self._cnt stopped = rtime() cps = float(self._cnt) / float(stopped - self._started) print ("{} calls/s ({} succeeded)".format(cps, self._total)) self._started = rtime() self._cnt = 0
def trigger_gc(self, details=None): """ Triggers a garbage collection. :returns: float -- Time consumed for GC in ms. """ self.msg.debug("{cls}.trigger_gc", cls=self.__class__.__name__) started = rtime() gc.collect() return 1000. * (rtime() - started)
def trigger_gc(self, details=None): """ Triggers a garbage collection. :returns: float -- Time consumed for GC in ms. """ if self.debug: log.msg("{}.trigger_gc".format(self.__class__.__name__)) started = rtime() gc.collect() return 1000. * (rtime() - started)
def trigger_gc(self, details = None): """ Triggers a garbage collection. :returns: float -- Time consumed for GC in ms. """ if self.debug: log.msg("{}.trigger_gc".format(self.__class__.__name__)) started = rtime() gc.collect() return 1000. * (rtime() - started)
def connectionMade(self): print("session ready") self._send_queue = deque() self.send_queued_stuff() self._stop_calling = False self._done = False self._cnt_outstanding = 0 self._started = None self._total = 0 self._debug = False lc = LoopingCall(self.print_stats) lc.start(1) def stop(): lc.stop() self._stop_calling = True self._done = True self._test_ended = rtime() self.stop() reactor.callLater(self.RUNTIME, stop) self._test_started = rtime() self.issue_calls()
def connectionMade(self): print ("session ready") self._send_queue = deque() self.send_queued_stuff() self._stop_calling = False self._done = False self._cnt_outstanding = 0 self._started = None self._total = 0 self._debug = False lc = LoopingCall(self.print_stats) lc.start(1) def stop(): lc.stop() self._stop_calling = True self._done = True self._test_ended = rtime() self.stop() reactor.callLater(self.RUNTIME, stop) self._test_started = rtime() self.issue_calls()
def _connect(self): if len(self._connected) < self._target: if self._pending <= self._low_watermark: #print("low watermark reached ({} pending)".format(self._pending)) self._connect_more() #else: #print len(self._connected) reactor.callLater(0.01, self._connect) else: self._do_print_stats = False self._ended = rtime() secs = self._ended - self._started conns_per_sec = float(len(self._connected)) / float(secs) print("all connected: {} in {} seconds ({} connections/sec)".format(len(self._connected), secs, conns_per_sec)) reactor.stop()
def run(self): print("Starting ..") self._started = rtime() self._ended = None self._print_stats() self._connect()
def _post(self, session, result): duration = round(1000. * (rtime() - self._started), 1) self._started = None return CmdRunResult(result, duration)
def _pre(self, session): if not session: raise Exception('not connected') self._started = rtime()
def stop(): lc.stop() self._stop_calling = True self._done = True self._test_ended = rtime() self.stop()