blob: 63b231aa52e8c9e41b535887a72c73efefa6340d [file] [log] [blame]
mblighedf430c2006-04-23 06:52:09 +00001import os
2from autotest_utils import *
3from error import *
4
mbligh7bb9dbc2006-04-23 18:41:40 +00005class profilers:
mbligh3a6d6ca2006-04-23 15:50:24 +00006 def __init__(self, job):
7 self.job = job
8 self.list = []
9 self.profdir = job.autodir + '/profilers'
10 self.tmpdir = job.tmpdir
mblighedf430c2006-04-23 06:52:09 +000011
mbligh72905562006-05-25 01:30:49 +000012 # add a profiler
mbligh9eb80ba2006-05-26 22:00:04 +000013 def add(self, profiler, *args):
mblighff88e4e2006-05-25 19:34:52 +000014 try:
15 sys.path.insert(0, self.job.profdir + '/' + profiler)
16 exec 'import ' + profiler
17 exec 'newprofiler = %s.%s(self)' % (profiler, profiler)
18 finally:
19 sys.path.pop(0)
mbligh3a6d6ca2006-04-23 15:50:24 +000020 newprofiler.name = profiler
21 newprofiler.bindir = self.profdir + '/' + profiler
22 newprofiler.srcdir = newprofiler.bindir + '/src'
23 newprofiler.tmpdir = self.tmpdir + '/' + profiler
mbligh72905562006-05-25 01:30:49 +000024 update_version(newprofiler.srcdir, newprofiler.version, newprofiler.setup)
mbligh9eb80ba2006-05-26 22:00:04 +000025 newprofiler.initialize(*args)
mbligh3a6d6ca2006-04-23 15:50:24 +000026 self.list.append(newprofiler)
mblighedf430c2006-04-23 06:52:09 +000027
28
mbligh72905562006-05-25 01:30:49 +000029 # remove a profiler
30 def delete(self, profiler):
mblighedf430c2006-04-23 06:52:09 +000031 nukeme = None
mbligh3a6d6ca2006-04-23 15:50:24 +000032 for p in self.list:
mblighedf430c2006-04-23 06:52:09 +000033 if (p.name == profiler):
mbligh72905562006-05-25 01:30:49 +000034 nukeme = p
35 self.list.remove(p)
mblighedf430c2006-04-23 06:52:09 +000036
37
mbligh72905562006-05-25 01:30:49 +000038 # are any profilers enabled ?
39 def present(self):
40 if self.list:
41 return 1
42 else:
43 return 0
44
45
46 # Start all enabled profilers
47 def start(self, test):
mbligh3a6d6ca2006-04-23 15:50:24 +000048 for p in self.list:
mbligh72905562006-05-25 01:30:49 +000049 p.start(test)
mblighedf430c2006-04-23 06:52:09 +000050
51
mbligh72905562006-05-25 01:30:49 +000052 # Stop all enabled profilers
53 def stop(self, test):
mbligh3a6d6ca2006-04-23 15:50:24 +000054 for p in self.list:
mbligh72905562006-05-25 01:30:49 +000055 p.stop(test)
mblighedf430c2006-04-23 06:52:09 +000056
57
mbligh72905562006-05-25 01:30:49 +000058 # Report on all enabled profilers
59 def report(self, test):
mbligh3a6d6ca2006-04-23 15:50:24 +000060 for p in self.list:
mbligh72905562006-05-25 01:30:49 +000061 p.report(test)
mblighedf430c2006-04-23 06:52:09 +000062