add parsing of keyvals to aiostress and unixbench



git-svn-id: http://test.kernel.org/svn/autotest/trunk@794 592f7852-d20e-0410-864c-8624ca9c26a4
diff --git a/client/tests/unixbench/unixbench.py b/client/tests/unixbench/unixbench.py
index d28c4d5..46e49ea 100755
--- a/client/tests/unixbench/unixbench.py
+++ b/client/tests/unixbench/unixbench.py
@@ -15,10 +15,15 @@
 	def execute(self, iterations = 1, args = ''):
 		vars = 'TMPDIR=\"%s\" RESULTDIR=\"%s\"' % (self.tmpdir, self.resultsdir)
 		profilers = self.job.profilers
+		keyval = open(self.resultsdir + '/keyval', 'w')
+
 		if not profilers.only():
 			for i in range(iterations):
 				os.chdir(self.srcdir)
 				system(vars + ' ./Run ' + args)
+				report = open(self.resultsdir + '/report')
+				_format_results(report, keyval)
+				
 
 		# Do a profiling run if necessary
 		if profilers.present():
@@ -26,3 +31,75 @@
 			system(vars + ' ./Run ' + args)
 			profilers.stop(self)
 			profilers.report(self)
+
+
+def _format_results(report, keyval):
+	for i in range(9):
+		report.next()
+	for line in report:
+		if not line.strip():
+			break
+
+		words = line.split()
+		key = '_'.join(words[:-6])
+		value = words[-6]
+		print >> keyval, '%s=%s' % (key, value)
+
+
+if __name__ == '__main__':
+	import sys
+	_format_results(sys.stdin, sys.stdout)
+
+
+""" Here is a sample report file:
+
+  BYTE UNIX Benchmarks (Version 4.1.0)
+  System -- Linux adrianbg 2.6.18.5 #1 SMP Thu J  Start Benchmark Run: Tue Sep 1
+   9 interactive users.
+   21:03:50 up 5 days,  7:38,  9 users,  load average: 0.71, 0.40, 0.25
+  lrwxrwxrwx 1 root root 4 Aug 15 09:53 /bin/sh -> bash
+  /bin/sh: symbolic link to `bash'
+  /dev/sda6            192149596  91964372  90424536  51% /home
+Dhrystone 2 using register variables     7918001.7 lps   (10.0 secs, 10 samples)
+System Call Overhead                     1427272.7 lps   (10.0 secs, 10 samples)
+Process Creation                          11508.6 lps   (30.0 secs, 3 samples)
+Execl Throughput                           4159.7 lps   (29.7 secs, 3 samples)
+File Read 1024 bufsize 2000 maxblocks    1708109.0 KBps  (30.0 secs, 3 samples)
+File Write 1024 bufsize 2000 maxblocks   788024.0 KBps  (30.0 secs, 3 samples)
+File Copy 1024 bufsize 2000 maxblocks    452986.0 KBps  (30.0 secs, 3 samples)
+File Read 256 bufsize 500 maxblocks      508752.0 KBps  (30.0 secs, 3 samples)
+File Write 256 bufsize 500 maxblocks     214772.0 KBps  (30.0 secs, 3 samples)
+File Copy 256 bufsize 500 maxblocks      143989.0 KBps  (30.0 secs, 3 samples)
+File Read 4096 bufsize 8000 maxblocks    2626923.0 KBps  (30.0 secs, 3 samples)
+File Write 4096 bufsize 8000 maxblocks   1175070.0 KBps  (30.0 secs, 3 samples)
+File Copy 4096 bufsize 8000 maxblocks    793041.0 KBps  (30.0 secs, 3 samples)
+Shell Scripts (1 concurrent)               4417.4 lpm   (60.0 secs, 3 samples)
+Shell Scripts (8 concurrent)               1109.0 lpm   (60.0 secs, 3 samples)
+Shell Scripts (16 concurrent)               578.3 lpm   (60.0 secs, 3 samples)
+Arithmetic Test (type = short)           1843690.0 lps   (10.0 secs, 3 samples)
+Arithmetic Test (type = int)             1873615.8 lps   (10.0 secs, 3 samples)
+Arithmetic Test (type = long)            1888345.9 lps   (10.0 secs, 3 samples)
+Arithmetic Test (type = float)           616260.3 lps   (10.0 secs, 3 samples)
+Arithmetic Test (type = double)          615942.1 lps   (10.0 secs, 3 samples)
+Arithoh                                  18864899.5 lps   (10.0 secs, 3 samples)
+Dc: sqrt(2) to 99 decimal places         161726.0 lpm   (30.0 secs, 3 samples)
+Recursion Test--Tower of Hanoi            89229.3 lps   (20.0 secs, 3 samples)
+
+
+                     INDEX VALUES
+TEST                                        BASELINE     RESULT      INDEX
+
+Dhrystone 2 using register variables        116700.0  7918001.7      678.5
+Double-Precision Whetstone                      55.0     1948.2      354.2
+Execl Throughput                                43.0     4159.7      967.4
+File Copy 1024 bufsize 2000 maxblocks         3960.0   452986.0     1143.9
+File Copy 256 bufsize 500 maxblocks           1655.0   143989.0      870.0
+File Copy 4096 bufsize 8000 maxblocks         5800.0   793041.0     1367.3
+Pipe Throughput                              12440.0  1048491.9      842.8
+Pipe-based Context Switching                  4000.0   300778.3      751.9
+Process Creation                               126.0    11508.6      913.4
+Shell Scripts (8 concurrent)                     6.0     1109.0     1848.3
+System Call Overhead                         15000.0  1427272.7      951.5
+                                                                 =========
+     FINAL SCORE                                                     902.1
+"""