commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] r7385 - gnuradio/branches/developers/eb/gcell/src/apps


From: eb
Subject: [Commit-gnuradio] r7385 - gnuradio/branches/developers/eb/gcell/src/apps
Date: Tue, 8 Jan 2008 20:07:36 -0700 (MST)

Author: eb
Date: 2008-01-08 20:07:35 -0700 (Tue, 08 Jan 2008)
New Revision: 7385

Added:
   gnuradio/branches/developers/eb/gcell/src/apps/split_and_avg_results.py
Log:
work-in-progress; ready to test on QS21

Added: gnuradio/branches/developers/eb/gcell/src/apps/split_and_avg_results.py
===================================================================
--- gnuradio/branches/developers/eb/gcell/src/apps/split_and_avg_results.py     
                        (rev 0)
+++ gnuradio/branches/developers/eb/gcell/src/apps/split_and_avg_results.py     
2008-01-09 03:07:35 UTC (rev 7385)
@@ -0,0 +1,102 @@
+#!/usr/bin/env python
+#
+# Copyright 2007 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:    1  elapsed_time:  26.117  njobs: 1e+06  us/job:  26.117
+nspes:  2  udelay:    1  elapsed_time:  23.585  njobs: 1e+06  us/job:  23.585
+"""
+
+import sys
+from optparse import OptionParser
+from pprint import pprint
+from gnuradio import eng_notation as en
+
+
+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.elapsed_per_job = self.elapsed_time/self.njobs
+
+    def __repr__(self):
+        return "<data nspes=%d work_per_job=%s elapsed_time=%s njobs=%s>" % (
+            self.nspes, en.num_to_str(self.work_per_job),
+            en.num_to_str(self.elapsed_time),
+            en.num_to_str(self.njobs))
+
+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
+
+if __name__ == '__main__':
+    main()


Property changes on: 
gnuradio/branches/developers/eb/gcell/src/apps/split_and_avg_results.py
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:eol-style
   + native





reply via email to

[Prev in Thread] Current Thread [Next in Thread]