Add print date method to base command class
authorAntoine Busque <antoinebusque@gmail.com>
Sat, 7 Mar 2015 00:49:25 +0000 (19:49 -0500)
committerAntoine Busque <antoinebusque@gmail.com>
Sat, 7 Mar 2015 00:49:25 +0000 (19:49 -0500)
lttnganalysescli/lttnganalysescli/command.py
lttnganalysescli/lttnganalysescli/cputop.py
lttnganalysescli/lttnganalysescli/io.py
lttnganalysescli/lttnganalysescli/irq.py
lttnganalysescli/lttnganalysescli/memtop.py
lttnganalysescli/lttnganalysescli/syscallstats.py

index 75a215f86a078cca35aad78fb8ca01df06f864b1..4e7ad79ad5c812b4e40ae48ee33a7aa92f45a5eb 100644 (file)
@@ -133,6 +133,14 @@ class Command:
             self.current_sec = event_sec
             self.start_ns = event.timestamp
 
+    def _print_date(self, begin_ns, end_ns):
+        date = 'Timerange: [%s, %s]' % (
+            common.ns_to_hour_nsec(begin_ns, gmt=self._arg_gmt,
+                                   multi_day=True),
+            common.ns_to_hour_nsec(end_ns, gmt=self._arg_gmt,
+                                   multi_day=True))
+        print(date)
+
     def _validate_transform_common_args(self, args):
         self._arg_path = args.path
 
index 0ecc9d7390c3a5fce9b9eaf70b9f015cc9b65b00..5fad5a09f172e4b13d1d67741c36578cb0c8f401 100644 (file)
@@ -99,11 +99,7 @@ class Cputop(Command):
         total_ns = end_ns - begin_ns
         graph = Pyasciigraph()
         values = []
-        print('Timerange: [%s, %s]' % (
-            common.ns_to_hour_nsec(begin_ns, gmt=self._arg_gmt,
-                                   multi_day=True),
-            common.ns_to_hour_nsec(end_ns, gmt=self._arg_gmt,
-                                   multi_day=True)))
+        self._print_date(begin_ns, end_ns)
         for tid in sorted(self.state.tids.values(),
                           key=operator.attrgetter('cpu_ns'), reverse=True):
             if self._arg_proc_list and tid.comm not in self._arg_proc_list:
index 24644d4c9855336c4c1ed252ed81b859013fb64f..819807b2f06a485584ef81e4d901c938ab5755a6 100644 (file)
@@ -751,11 +751,7 @@ class IoAnalysis(Command):
         self.iostats_output_disk()
 
     def _print_results(self, begin_ns, end_ns):
-        print('Timerange: [%s, %s]' % (
-            common.ns_to_hour_nsec(begin_ns, gmt=self._arg_gmt,
-                                   multi_day=True),
-            common.ns_to_hour_nsec(end_ns, gmt=self._arg_gmt,
-                                   multi_day=True)))
+        self._print_date(begin_ns, end_ns)
         if self._arg_usage:
             self.iotop_output()
         self.syscalls_stats = self.compute_syscalls_latency_stats(end_ns)
index e50baea5abc5c548c5f7e2db037783a0b276a67a..2dab7831bc6eda396816e796e843d0d15655c98a 100644 (file)
@@ -301,14 +301,6 @@ class IrqAnalysisCommand(Command):
         if self._arg_log:
             self._print_irq_log()
 
-    def _print_date(self, begin_ns, end_ns):
-        date = 'Timerange: [%s, %s]' % (
-            common.ns_to_hour_nsec(begin_ns, gmt=self._arg_gmt,
-                                   multi_day=True),
-            common.ns_to_hour_nsec(end_ns, gmt=self._arg_gmt,
-                                   multi_day=True))
-        print(date)
-
     def _print_stats(self, begin_ns, end_ns):
         self._print_date(begin_ns, end_ns)
 
index 82ee005f35c31bd2be4ab9366f881b28a6944da3..cf2b82938e9e85a34de09bcd4240b1d7f7d5ba97 100644 (file)
@@ -82,12 +82,7 @@ class Memtop(Command):
         return True
 
     def _print_results(self, begin_ns, end_ns):
-        print('Timerange: [%s, %s]' % (
-            common.ns_to_hour_nsec(begin_ns, gmt=self._arg_gmt,
-                                   multi_day=True),
-            common.ns_to_hour_nsec(end_ns, gmt=self._arg_gmt,
-                                   multi_day=True)))
-
+        self._print_date(begin_ns, end_ns)
         self._print_per_tid_alloc()
         self._print_per_tid_freed()
         self._print_total_alloc_freed()
index a53d18e350b9f12e68ee4b3398f2fdb940e79bc3..18ef071f5afc8cc24fcfaf959123ebbc92f4ec83 100644 (file)
@@ -83,11 +83,7 @@ class SyscallsAnalysis(Command):
         return True
 
     def _print_results(self, begin_ns, end_ns):
-        print('Timerange: [%s, %s]' % (
-            common.ns_to_hour_nsec(begin_ns, gmt=self._arg_gmt,
-                                   multi_day=True),
-            common.ns_to_hour_nsec(end_ns, gmt=self._arg_gmt,
-                                   multi_day=True)))
+        self._print_date(begin_ns, end_ns)
         strformat = '{:<28} {:>14} {:>14} {:>14} {:>12} {:>10}  {:<14}'
         print('Per-TID syscalls statistics (usec)')
         for tid in sorted(self.state.tids.values(),
This page took 0.028792 seconds and 5 git commands to generate.