Replace Pyasciigraph by termgraph in memtop
authorAntoine Busque <abusque@efficios.com>
Fri, 15 Jan 2016 21:47:28 +0000 (16:47 -0500)
committerAntoine Busque <abusque@efficios.com>
Thu, 11 Feb 2016 18:58:52 +0000 (13:58 -0500)
Signed-off-by: Antoine Busque <abusque@efficios.com>
lttnganalyses/cli/memtop.py

index a00ecfb3e92d18f9c6a093059e85bce3d4461580..2461e2324ff42d71eff50019947aa3f1a5f9d356 100644 (file)
@@ -25,8 +25,8 @@
 import operator
 from .command import Command
 from ..core import memtop
-from ..ascii_graph import Pyasciigraph
 from . import mi
+from . import termgraph
 
 
 class Memtop(Command):
@@ -154,17 +154,17 @@ class Memtop(Command):
         return result_table
 
     def _print_per_tid_result(self, result_table, title):
-        graph = Pyasciigraph()
-        values = []
-
-        for row in result_table.rows:
-            process_do = row.process
-            pages = row.pages.value
-            values.append(('%s (%d)' % (process_do.name, process_do.tid),
-                           pages))
+        graph = termgraph.BarGraph(
+            title=title,
+            unit='pages',
+            get_value=lambda row: row.pages.value,
+            get_label=lambda row: '%s (%d)' % (row.process.name,
+                                               row.process.tid),
+            label_header='Process',
+            data=result_table.rows
+        )
 
-        for line in graph.graph(title, values, unit=' pages'):
-            print(line)
+        graph.print_graph()
 
     def _print_per_tid_allocd(self, result_table):
         self._print_per_tid_result(result_table, 'Per-TID Memory Allocations')
This page took 0.024967 seconds and 5 git commands to generate.