Moved to_seconds, extract_all_time_results to autotest_utils.py for reuse
    
Signed-off-by: Ryan Stutsman <stutsman@google.com>
    
Patch comes as a request from mbligh.  This simply moves to_seconds and
the time results extraction to autotest_utils.py and adds a small bit of
documentation.




git-svn-id: http://test.kernel.org/svn/autotest/trunk@582 592f7852-d20e-0410-864c-8624ca9c26a4
diff --git a/client/bin/autotest_utils.py b/client/bin/autotest_utils.py
index 2d4dd43..a3bf50b 100755
--- a/client/bin/autotest_utils.py
+++ b/client/bin/autotest_utils.py
@@ -494,3 +494,18 @@
 	nodes = max(len(numa_nodes()), 1)
 	return ((memtotal() * 1024) / nodes)
 
+
+def to_seconds(time_string):
+	"""Converts a string in M+:SS.SS format to S+.SS"""
+	elts = time_string.split(':')
+	if len(elts) == 1:
+		return time_string
+	return str(int(elts[0]) * 60 + float(elts[1]))
+
+
+def extract_all_time_results(results_string):
+	"""Extract user, system, and elapsed times into a list of tuples"""
+	pattern = re.compile(r"(.*?)user (.*?)system (.*?)elapsed")
+	results = []
+	for result in pattern.findall(results):
+		results.append(tuple([to_seconds(elt) for elt in result]))