commit 1c3fc574c3a2303189306bdc74c32add20423a03 Author: Damian Johnson atagar@torproject.org Date: Sat Apr 16 12:09:25 2016 -0700
Move SYSTEM_CALL_TIME to Stem
On reflection SYSTEM_CALL_TIME better belongs in Stem itself. No need any longer for this wrapper. --- nyx/panel/header.py | 24 +----------------------- test/panel/header.py | 5 ----- 2 files changed, 1 insertion(+), 28 deletions(-)
diff --git a/nyx/panel/header.py b/nyx/panel/header.py index f29d232..4e4f922 100644 --- a/nyx/panel/header.py +++ b/nyx/panel/header.py @@ -31,13 +31,6 @@ MIN_DUAL_COL_WIDTH = 141 # minimum width where we'll show two columns SHOW_FD_THRESHOLD = 60 # show file descriptor usage if usage is over this percentage UPDATE_RATE = 5 # rate in seconds at which we refresh
-# Tracks total time spent shelling out to other commands like 'ps' and -# 'netstat', so we can account for it as part of our cpu time. - -SYSTEM_CALL_TIME = 0.0 -SYSTEM_CALL_TIME_LOCK = threading.RLock() -SYSTEM_CALL_ORIG = stem.util.system.call - CONFIG = conf.config_dict('nyx', { 'attr.flag_colors': {}, 'attr.version_status_colors': {}, @@ -45,21 +38,6 @@ CONFIG = conf.config_dict('nyx', { })
-def call_wrapper(*args, **kwargs): - global SYSTEM_CALL_TIME - - start_time = time.time() - - try: - return SYSTEM_CALL_ORIG(*args, **kwargs) - finally: - with SYSTEM_CALL_TIME_LOCK: - SYSTEM_CALL_TIME += time.time() - start_time - - -stem.util.system.call = call_wrapper - - class HeaderPanel(nyx.panel.Panel, threading.Thread): """ Top area containing tor settings and system information. @@ -307,7 +285,7 @@ class Sampling(object):
pid = controller.get_pid('') tor_resources = nyx.tracker.get_resource_tracker().get_value() - nyx_total_cpu_time = sum(os.times()[:3], SYSTEM_CALL_TIME) + nyx_total_cpu_time = sum(os.times()[:3], stem.util.system.SYSTEM_CALL_TIME)
or_listeners = controller.get_listeners(stem.control.Listener.OR, []) control_listeners = controller.get_listeners(stem.control.Listener.CONTROL, []) diff --git a/test/panel/header.py b/test/panel/header.py index 6e0f275..e601f00 100644 --- a/test/panel/header.py +++ b/test/panel/header.py @@ -18,11 +18,6 @@ from mock import patch, Mock
class TestHeader(unittest.TestCase): - def test_system_call_time_tracked(self): - initial = nyx.panel.header.SYSTEM_CALL_TIME - stem.util.system.call('sleep 0.5') - self.assertTrue(nyx.panel.header.SYSTEM_CALL_TIME - initial > 0.4) - @patch('nyx.panel.header.tor_controller') @patch('nyx.tracker.get_resource_tracker') @patch('time.time', Mock(return_value = 1234.5))
tor-commits@lists.torproject.org