[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [arm/master] Using get_resource_usage() results as a named tuple



commit 737e6e7c3d1856780317a74ad53b7b3c87705bfd
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Mon Oct 28 10:42:58 2013 -0700

    Using get_resource_usage() results as a named tuple
    
    Referencing the returned results by their attribute name rather than position.
    This allows the caller's code to be a bit more self-documenting.
---
 arm/graphing/resourceStats.py |    6 +++---
 arm/headerPanel.py            |    8 ++++----
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/arm/graphing/resourceStats.py b/arm/graphing/resourceStats.py
index 03a8654..5be4ba8 100644
--- a/arm/graphing/resourceStats.py
+++ b/arm/graphing/resourceStats.py
@@ -47,9 +47,9 @@ class ResourceStats(graphPanel.GraphStats):
       resourceTracker = arm.util.tracker.get_resource_tracker()
 
       if resourceTracker and not resourceTracker.last_query_failed():
-        primary, _, secondary, _ = resourceTracker.get_resource_usage()
-        primary *= 100        # decimal percentage to whole numbers
-        secondary /= 1048576  # translate size to MB so axis labels are short
+        resources = resourceTracker.get_resource_usage()
+        primary = resources.cpu_sample * 100  # decimal percentage to whole numbers
+        secondary = resources.memory_bytes / 1048576  # translate size to MB so axis labels are short
         self.runCount = resourceTracker.run_counter()
 
     self._processEvent(primary, secondary)
diff --git a/arm/headerPanel.py b/arm/headerPanel.py
index b559ec8..629c84c 100644
--- a/arm/headerPanel.py
+++ b/arm/headerPanel.py
@@ -571,11 +571,11 @@ class HeaderPanel(panel.Panel, threading.Thread):
         self.vals["stat/rss"] = "0"
         self.vals["stat/%mem"] = "0"
       else:
-        cpuUsage, _, memUsage, memUsagePercent = resourceTracker.get_resource_usage()
+        resources = resourceTracker.get_resource_usage()
         self._lastResourceFetch = resourceTracker.run_counter()
-        self.vals["stat/%torCpu"] = "%0.1f" % (100 * cpuUsage)
-        self.vals["stat/rss"] = str(memUsage)
-        self.vals["stat/%mem"] = "%0.1f" % (100 * memUsagePercent)
+        self.vals["stat/%torCpu"] = "%0.1f" % (100 * resources.cpu_sample)
+        self.vals["stat/rss"] = str(resources.memory_bytes)
+        self.vals["stat/%mem"] = "%0.1f" % (100 * resources.memory_percent)
 
     # determines the cpu time for the arm process (including user and system
     # time of both the primary and child processes)



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits