aboutsummaryrefslogtreecommitdiff
path: root/deprecated/mem_tests/total_mem_actual.py
blob: d2a0cedf5004db6867c8783fcd94e29402ddf82e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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))