[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [arm/master] Revising ResourceStats class
commit 833afb6daee873396e7d33c4ec00adae43225030
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date: Tue Oct 21 08:29:34 2014 -0700
Revising ResourceStats class
Nothing much. Main difference is that we only registered stats if we had a new
measurement. This was incorrect since we're supposed to register an update
every second (not be limited by the rate of the tracker).
I dislike the bytes => MB => bytes converting. Both this stat and bandwidth do
this to shorten the y-axis labels but I'm starting to wonder if we should
sacrifice a little data for proper labeling. Something to decide when revising
the GraphPanel itself.
---
arm/graph_panel.py | 20 ++++----------------
1 file changed, 4 insertions(+), 16 deletions(-)
diff --git a/arm/graph_panel.py b/arm/graph_panel.py
index e65e623..36967c2 100644
--- a/arm/graph_panel.py
+++ b/arm/graph_panel.py
@@ -377,15 +377,11 @@ class ConnectionStats(GraphCategory):
class ResourceStats(GraphCategory):
"""
- System resource usage tracker.
+ Tracks cpu and memory usage of the tor process.
"""
TITLE = 'System Resources'
- def __init__(self, clone = None):
- GraphCategory.__init__(self)
- self._last_counter = clone._last_counter if clone else None
-
def primary_header(self, width):
avg = self.primary.total / max(1, self.primary.tick)
return 'CPU (%0.1f%%, avg: %0.1f%%):' % (self.primary.latest_value, avg)
@@ -401,17 +397,9 @@ class ResourceStats(GraphCategory):
return 'Memory (%s, avg: %s):' % (usage_label, avg_label)
def bandwidth_event(self, event):
- """
- Fetch the cached measurement of resource usage from the ResourceTracker.
- """
-
- resource_tracker = arm.util.tracker.get_resource_tracker()
-
- if resource_tracker and resource_tracker.run_counter() != self._last_counter:
- resources = resource_tracker.get_value()
- self.primary.update(resources.cpu_sample * 100) # decimal percentage to whole numbers
- self.secondary.update(resources.memory_bytes / 1048576) # translate size to MB so axis labels are short
- self._last_counter = resource_tracker.run_counter()
+ resources = arm.util.tracker.get_resource_tracker().get_value()
+ self.primary.update(resources.cpu_sample * 100) # decimal percentage to whole numbers
+ self.secondary.update(resources.memory_bytes / 1048576) # translate size to MB so axis labels are short
class GraphPanel(panel.Panel):
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits