aboutsummaryrefslogtreecommitdiff
path: root/deprecated/mem_tests/total_mem_actual.py
diff options
context:
space:
mode:
Diffstat (limited to 'deprecated/mem_tests/total_mem_actual.py')
-rwxr-xr-xdeprecated/mem_tests/total_mem_actual.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/deprecated/mem_tests/total_mem_actual.py b/deprecated/mem_tests/total_mem_actual.py
new file mode 100755
index 00000000..d2a0cedf
--- /dev/null
+++ b/deprecated/mem_tests/total_mem_actual.py
@@ -0,0 +1,37 @@
+#!/usr/bin/python2
+"""Parses the actual memory usage from TCMalloc.
+
+This goes through logs that have the actual allocated memory (not sampled) in
+the logs. The output is of the form of:
+
+time (in seconds from some base time), amount of memory allocated by the
+application
+
+"""
+
+import argparse
+from cros_utils import compute_total_diff
+from datetime import datetime
+
+pretty_print = True
+
+parser = argparse.ArgumentParser()
+parser.add_argument('filename')
+args = parser.parse_args()
+
+my_file = open(args.filename)
+output_file = open('raw_memory_data.csv', 'a')
+
+base_time = datetime(2014, 6, 11, 0, 0)
+prev_line = ''
+half_entry = (None, None)
+
+for line in my_file:
+ if 'Output Heap Stats:' in line:
+ total_diff = compute_total_diff(line, base_time)
+ half_entry = (total_diff, None)
+ if 'Bytes in use by application' in line:
+ total_diff = half_entry[0]
+ memory_used = int(line.strip().split()[1])
+ half_entry = (None, None)
+ output_file.write('{0},{1}\n'.format(total_diff, memory_used))