aboutsummaryrefslogtreecommitdiff
path: root/mem_tests/utils.py
diff options
context:
space:
mode:
authorSoumya Basu <sbasu@google.com>2014-07-09 16:30:11 -0700
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-07-18 22:41:47 +0000
commit50ef334ec9d72f3bfa06be51a493a1ff8f4c3162 (patch)
tree75a43e9ddaf028a9251325700812fa3468659c64 /mem_tests/utils.py
parent74b3d3234dc857ebee3af81faa3f8f420ac6ecce (diff)
downloadtoolchain-utils-50ef334ec9d72f3bfa06be51a493a1ff8f4c3162.tar.gz
Add framework for parsing logs obtained from heap measurements in ChromeOS machines.
BUG=None TEST=Manual testing on chrome logs. Change-Id: I48f0062180fd6ee723ccbff047b5fea625e4e3e1 Reviewed-on: https://chrome-internal-review.googlesource.com/168652 Reviewed-by: Simon Que <sque@google.com> Tested-by: Soumya Basu <sbasu@google.com> Commit-Queue: Soumya Basu <sbasu@google.com>
Diffstat (limited to 'mem_tests/utils.py')
-rw-r--r--mem_tests/utils.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/mem_tests/utils.py b/mem_tests/utils.py
new file mode 100644
index 00000000..54dbcc2d
--- /dev/null
+++ b/mem_tests/utils.py
@@ -0,0 +1,23 @@
+#! /usr/bin/python
+
+"""Utility functions for the memory tests.
+"""
+
+from datetime import datetime
+
+def compute_total_diff(line, base_time):
+ """
+ Computes the difference in time the line was recorded from the base time.
+
+ An example of a line is:
+ [4688:4688:0701/010151:ERROR:perf_provider_chromeos.cc(228)]...
+
+ Here, the month is 07, the day is 01 and the time is 01:01:51.
+
+ line- the line that contains the time the record was taken
+ base_time- the base time to measure our timestamp from
+ """
+ date = line.strip().split(":")[2].split("/")
+ timestamp = datetime(2014, int(date[0][0:2]), int(date[0][2:4]),
+ int(date[1][0:2]), int(date[1][2:4]), int(date[1][4:6]))
+ return (timestamp - base_time).total_seconds()