aboutsummaryrefslogtreecommitdiff
path: root/mem_tests/clean_data.py
diff options
context:
space:
mode:
authorStephen Hines <srhines@google.com>2017-02-08 10:42:04 +0000
committerandroid-build-merger <android-build-merger@google.com>2017-02-08 10:42:04 +0000
commitc5804ce784c39d6cf4f69139ab3197d989181cf9 (patch)
tree87b3a32b13c392939d66fa93105896f5df0736a6 /mem_tests/clean_data.py
parentbaba90fd78c18585d22430dc95c748f96ad0c772 (diff)
parent9c6fa5f9e514c743e62be0ee401c12e10c94d7f1 (diff)
downloadtoolchain-utils-c5804ce784c39d6cf4f69139ab3197d989181cf9.tar.gz
Merge remote-tracking branch 'aosp/mirror-chromium-master' into initial_import am: 870a8df6fc
am: 9c6fa5f9e5 Change-Id: Ie306363c46445f59e341b69121c4b0e113ad79b2
Diffstat (limited to 'mem_tests/clean_data.py')
-rwxr-xr-xmem_tests/clean_data.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/mem_tests/clean_data.py b/mem_tests/clean_data.py
new file mode 100755
index 00000000..f9a11e75
--- /dev/null
+++ b/mem_tests/clean_data.py
@@ -0,0 +1,29 @@
+#! /usr/bin/python
+"""Cleans output from other scripts to eliminate duplicates.
+
+When frequently sampling data, we see that records occasionally will contain
+the same timestamp (due to perf recording twice in the same second).
+
+This removes all of the duplicate timestamps for every record. Order with
+respect to timestamps is not preserved. Also, the assumption is that the log
+file is a csv with the first value in each row being the time in seconds from a
+standard time.
+
+"""
+
+import argparse
+
+parser = argparse.ArgumentParser()
+parser.add_argument('filename')
+args = parser.parse_args()
+
+my_file = open(args.filename)
+output_file = open('clean2.csv', 'a')
+dictionary = dict()
+
+for line in my_file:
+ new_time = int(line.split(',')[0])
+ dictionary[new_time] = line
+
+for key in dictionary.keys():
+ output_file.write(dictionary[key])