3 # Copyright 2007,2008 Free Software Foundation, Inc.
5 # This file is part of GNU Radio
7 # GNU Radio is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3, or (at your option)
12 # GNU Radio is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License along
18 # with this program; if not, write to the Free Software Foundation, Inc.,
19 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 input file looks like this:
25 nspes: 1 udelay: 10 elapsed_time: 6.842 njobs: 500000 speedup: 0.731
26 nspes: 2 udelay: 10 elapsed_time: 4.093 njobs: 500000 speedup: 1.221
30 from optparse import OptionParser
31 from pprint import pprint
34 def __init__(self, nspes, work_per_job, elapsed_time, njobs):
36 self.work_per_job = work_per_job # seconds
37 self.elapsed_time = elapsed_time # seconds
39 self.speedup = work_per_job * njobs / elapsed_time
42 return "<data nspes=%d work_per_job=%s elapsed_time=%s njobs=%s speedup=%s>" % (
43 self.nspes, (self.work_per_job),
51 t = x.work_per_job - y.work_per_job
61 usage = "usage: %prog [options] input_filename"
62 parser = OptionParser(usage=usage)
63 (options, args) = parser.parse_args()
67 input_filename = args[0]
71 for line in open(input_filename, "r"):
74 work_per_job = int(s[3]) * 1e-6
75 elapsed_time = float(s[5])
77 d = data(nspes, work_per_job, elapsed_time, njobs)
79 # collect lists that have the same values for nspes and work_per_job
80 # so we can generate an average elapsed_time from all observations
81 key = (nspes, work_per_job)
87 for k, v in m.iteritems():
88 total_elapsed_time = sum([x.elapsed_time for x in v])
89 r.append(data(v[0].nspes,
91 total_elapsed_time/len(v),
98 print t.nspes, t.work_per_job, t.elapsed_time, t.njobs, t.speedup
100 if __name__ == '__main__':