X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=gcell%2Fapps%2Fsplit_and_avg_results.py;fp=gcell%2Fapps%2Fsplit_and_avg_results.py;h=8a750fac9d0dd542ad438527936ae8c96653c645;hb=35e43e8d8c271e6842191cac3fc3f2f88a861183;hp=0000000000000000000000000000000000000000;hpb=ea29b08aeb54227e6628f655ccfdb96fe4d8c378;p=debian%2Fgnuradio diff --git a/gcell/apps/split_and_avg_results.py b/gcell/apps/split_and_avg_results.py new file mode 100755 index 00000000..8a750fac --- /dev/null +++ b/gcell/apps/split_and_avg_results.py @@ -0,0 +1,101 @@ +#!/usr/bin/env python +# +# Copyright 2007,2008 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# + +""" +input file looks like this: + +nspes: 1 udelay: 10 elapsed_time: 6.842 njobs: 500000 speedup: 0.731 +nspes: 2 udelay: 10 elapsed_time: 4.093 njobs: 500000 speedup: 1.221 +""" + +import sys +from optparse import OptionParser +from pprint import pprint + +class data(object): + def __init__(self, nspes, work_per_job, elapsed_time, njobs): + self.nspes = nspes + self.work_per_job = work_per_job # seconds + self.elapsed_time = elapsed_time # seconds + self.njobs = njobs + self.speedup = work_per_job * njobs / elapsed_time + + def __repr__(self): + return "" % ( + self.nspes, (self.work_per_job), + (self.elapsed_time), + (self.njobs), + (self.speedup)) + +def cmp_data(x, y): + t = x.nspes - y.nspes + if t == 0: + t = x.work_per_job - y.work_per_job + if t < 0: + return -1 + elif t > 0: + return +1 + else: + return 0 + return t + +def main(): + usage = "usage: %prog [options] input_filename" + parser = OptionParser(usage=usage) + (options, args) = parser.parse_args() + if len(args) != 1: + parser.print_help() + raise SystemExit, 1 + input_filename = args[0] + + + m = {} + for line in open(input_filename, "r"): + s = line.split() + nspes = int(s[1]) + work_per_job = int(s[3]) * 1e-6 + elapsed_time = float(s[5]) + njobs = float(s[7]) + d = data(nspes, work_per_job, elapsed_time, njobs) + + # collect lists that have the same values for nspes and work_per_job + # so we can generate an average elapsed_time from all observations + key = (nspes, work_per_job) + v = m.get(key, []) + v.append(d) + m[key] = v + + r = [] + for k, v in m.iteritems(): + total_elapsed_time = sum([x.elapsed_time for x in v]) + r.append(data(v[0].nspes, + v[0].work_per_job, + total_elapsed_time/len(v), + v[0].njobs)) + + r.sort(cmp_data) + + #pprint(r) + for t in r: + print t.nspes, t.work_per_job, t.elapsed_time, t.njobs, t.speedup + +if __name__ == '__main__': + main()