3 # Copyright 2005,2006,2007 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
18 # along with GNU Radio; see the file COPYING. If not, write to
19 # the Free Software Foundation, Inc., 51 Franklin Street,
20 # Boston, MA 02110-1301, USA.
25 from optparse import OptionParser
26 from gnuradio import gr
27 from gnuradio.eng_option import eng_option
29 def make_random_complex_tuple(L):
32 result.append(complex(random.uniform(-1000,1000),
33 random.uniform(-1000,1000)))
36 def benchmark(name, creator, dec, ntaps, total_test_size, block_size):
40 taps = make_random_complex_tuple(ntaps)
41 src = gr.vector_source_c(make_random_complex_tuple(block_size), True)
42 head = gr.head(gr.sizeof_gr_complex, int(total_test_size))
43 op = creator(dec, taps)
44 dst = gr.null_sink(gr.sizeof_gr_complex)
45 tb.connect(src, head, op, dst)
50 print "%16s: taps: %4d input: %4g, time: %6.3f taps/sec: %10.4g" % (
51 name, ntaps, total_test_size, delta, ntaps*total_test_size/delta)
54 parser = OptionParser(option_class=eng_option)
55 parser.add_option("-n", "--ntaps", type="int", default=256)
56 parser.add_option("-t", "--total-input-size", type="eng_float", default=40e6)
57 parser.add_option("-b", "--block-size", type="intx", default=50000)
58 parser.add_option("-d", "--decimation", type="int", default=1)
59 (options, args) = parser.parse_args()
65 total_input_size = options.total_input_size
66 block_size = options.block_size
67 dec = options.decimation
69 benchmark("gr.fir_filter_ccc", gr.fir_filter_ccc,
70 dec, ntaps, total_input_size, block_size)
71 benchmark("gr.fft_filter_ccc", gr.fft_filter_ccc,
72 dec, ntaps, total_input_size, block_size)
74 if __name__ == '__main__':