blob: 2d0a3ca778fcc5efdb5ddc8b0ad09edd10477461 [file] [log] [blame]
mblighb8a14e32006-05-06 00:17:35 +00001import test, pickle
mblighf4c35322006-03-13 01:01:10 +00002from autotest_utils import *
3
apw7a0d5782006-04-21 14:21:17 +00004class kernbench(test.test):
mbligh96aee2a2006-05-03 16:28:26 +00005 version = 1
6
mblighb8a14e32006-05-06 00:17:35 +00007 def setup(self):
apw7d5477a2007-03-13 16:24:12 +00008 #
9 # If we have a local copy of the 2.6.14 tarball use that
10 # else let the kernel object use the defined mirrors
11 # to obtain it.
12 #
mbligh4f6243c2006-08-29 06:15:15 +000013 # http://kernel.org/pub/linux/kernel/v2.6/linux-2.6.14.tar.bz2
apw7d5477a2007-03-13 16:24:12 +000014 #
15 tarball = None
16 for dir in (self.bindir, '/usr/local/src'):
17 path = os.path.join(dir, 'linux-2.6.14.tar.bz2')
18 if os.path.exists(path):
19 tarball = path
20 break
21 if not tarball:
22 tarball = '2.6.14'
23
mbligh931ee5e2006-12-07 19:34:10 +000024 kernel = self.job.kernel(tarball, self.tmpdir, self.srcdir)
apwc30cbd32006-12-05 12:16:24 +000025 kernel.config(defconfig=True)
mblighb8a14e32006-05-06 00:17:35 +000026 # have to save this off, as we might use it in another run
27 kernel.pickle_dump(self.srcdir + '/.pickle')
mblighf4c35322006-03-13 01:01:10 +000028
29
mbligh82641862006-04-23 06:21:36 +000030 def execute(self, iterations = 1, threads = 2 * count_cpus()):
mblighb8a14e32006-05-06 00:17:35 +000031 kernel = pickle.load(open(self.srcdir + '/.pickle', 'r'))
mbligh931ee5e2006-12-07 19:34:10 +000032 kernel.job = self.job
mbligh82641862006-04-23 06:21:36 +000033 print "kernbench x %d: %d threads" % (iterations, threads)
34
mblighb8a14e32006-05-06 00:17:35 +000035 kernel.build_timed(threads) # warmup run
mblighca07e4d2006-11-26 04:31:29 +000036 for i in range(iterations):
mblighb8a14e32006-05-06 00:17:35 +000037 logfile = self.resultsdir+'/time.%d' % i
38 kernel.build_timed(threads, logfile)
mblighf4c35322006-03-13 01:01:10 +000039
mbligh72905562006-05-25 01:30:49 +000040 # Do a profiling run if necessary
41 profilers = self.job.profilers
42 if profilers.present():
43 profilers.start(self)
44 logfile = self.resultsdir+'/time.profile'
45 kernel.build_timed(threads, logfile)
46 profilers.stop(self)
47 profilers.report(self)
48
mblighb8a14e32006-05-06 00:17:35 +000049 kernel.clean() # Don't leave litter lying around
50 os.chdir(self.resultsdir)
mbligh39aa03c2006-11-25 23:11:22 +000051 system("grep -h elapsed time.* > time")