typo sandbox/hyokeun/profiling
authorhyokeun.jeon <hyokeun.jeon@samsung.com>
Mon, 2 Aug 2021 10:55:22 +0000 (19:55 +0900)
committerhyokeun.jeon <hyokeun.jeon@samsung.com>
Mon, 2 Aug 2021 10:55:22 +0000 (19:55 +0900)
Change-Id: I3dd0d5b25f11b489f4586ca64f744cd4e08911f6

bsr/bsr/utility/monitoring.py

index 3116ceae1ce22456f0fa8c75ef3d3101ae66ef91..312b72828aa61ae1f983a65fc1046320d0af15a7 100755 (executable)
@@ -36,10 +36,11 @@ class Monitoring:
         values = []
 
         if os.path.isfile(target_file):
-            with open(target_file, 'r') as cpu_rec:
-                for item in cpu_rec.readlines()[1:]:
-                    tstamp, usage = item.strip().split(',')
-                    values.append([int(tstamp), float(usage)])
+            with open(target_file, 'r') as hw_rec:
+                for item in hw_rec.readlines()[1:]:
+                    tstamp, cpu_usage, mem_usage = item.strip().split(',')
+                    values.append([int(tstamp), \
+                                   round(float(cpu_usage), 2), round(float(mem_usage), 2)])
 
         return values
 
@@ -85,11 +86,11 @@ while True:
         """Remove log file"""
 
         if os.path.isfile(target_file):
-            with open(target_file, 'r') as hw_rec:
-                for item in hw_rec.readlines()[1:]:
-                    tstamp, cpu_usage, mem_usage = item.strip().split(',')
-                    values.append([int(tstamp), \
-                                   round(float(cpu_usage), 2), round(float(mem_usage), 2)])
+            with open(target_file, 'r') as record_file:
+                pid = int(record_file.readline().strip())
+            self.stop_recording(pid)
+            if preserve_file is False and os.path.isfile(target_file):
+                os.remove(target_file)
 
     def stop_recording_without_cleanup(self, target_file):
         """Stop the process"""