diff options
author | Josh Blum | 2013-01-14 00:33:09 -0800 |
---|---|---|
committer | Josh Blum | 2013-01-14 00:33:09 -0800 |
commit | 0c8dc58819a931f81769e36f658d73611aba86a9 (patch) | |
tree | 38e7a6c139b2c7d148dd0cf642a10feed5df9f2d | |
parent | 7fa04e9f9684d5d25fae20d67a255ccdd27651ad (diff) | |
download | sandhi-0c8dc58819a931f81769e36f658d73611aba86a9.tar.gz sandhi-0c8dc58819a931f81769e36f658d73611aba86a9.tar.bz2 sandhi-0c8dc58819a931f81769e36f658d73611aba86a9.zip |
benchmark: added a filter test and delay test
-rw-r--r-- | benchmark/bm_registry.py | 24 | ||||
-rw-r--r-- | benchmark/run_benchmarks.py | 2 | ||||
-rw-r--r-- | benchmark/tb_filter_block.py | 77 | ||||
-rw-r--r-- | benchmark/tb_grextras_delay.py | 25 |
4 files changed, 127 insertions, 1 deletions
diff --git a/benchmark/bm_registry.py b/benchmark/bm_registry.py index 26e64da..e097e43 100644 --- a/benchmark/bm_registry.py +++ b/benchmark/bm_registry.py @@ -45,7 +45,31 @@ BENCHMARK_MANY_11_BLOCKS = tokwargs( to_result = lambda t: 1e8/t ) +BENCHMARK_FILTER_BLOCK = tokwargs( + wat='Benchmark the schedulers with a filter block', + moar='''TODO''', + tests = [ + tokwargs(wat='GRAS decim FIR', args=['tb_filter_block.py', '--num', '1e7', '--which', 'dfir'], env=GRAS_ENV), + tokwargs(wat='GR decim FIR', args=['tb_filter_block.py', '--num', '1e7', '--which', 'dfir'], env=GR_ENV), + tokwargs(wat='GRAS resampler', args=['tb_filter_block.py', '--num', '1e7', '--which', 'resamp'], env=GRAS_ENV), + tokwargs(wat='GR resampler', args=['tb_filter_block.py', '--num', '1e7', '--which', 'resamp'], env=GR_ENV), + ], + to_result = lambda t: 1e7/t +) + +BENCHMARK_DELAY_BLOCKS = tokwargs( + wat='Benchmark GrExtras vs gr-core delay block', + moar='''TODO''', + tests = [ + tokwargs(wat='GrExtras Delay\n(zero-copy)', args=['tb_grextras_delay.py', '1e8', 'extras_delay'], env=GRAS_ENV), + tokwargs(wat='gr-core Delay\n(mem-copy)', args=['tb_grextras_delay.py', '1e8', 'core_delay'], env=GRAS_ENV), + ], + to_result = lambda t: 1e8/t +) + BENCHMARKS = ( BENCHMARK_MATH_OPS, BENCHMARK_MANY_11_BLOCKS, + BENCHMARK_FILTER_BLOCK, + BENCHMARK_DELAY_BLOCKS, ) diff --git a/benchmark/run_benchmarks.py b/benchmark/run_benchmarks.py index 7686451..5405677 100644 --- a/benchmark/run_benchmarks.py +++ b/benchmark/run_benchmarks.py @@ -38,7 +38,7 @@ def do_a_benchmark(bm): for run in bm['tests']: test_name = run['wat'] print '-'*(len(test_name)+25) - print '-- running test:', test_name + print '-- running test:', test_name.replace('\n', ' ') print '-'*(len(test_name)+25) test_names.append(test_name) args = run['args'] diff --git a/benchmark/tb_filter_block.py b/benchmark/tb_filter_block.py new file mode 100644 index 0000000..df56a22 --- /dev/null +++ b/benchmark/tb_filter_block.py @@ -0,0 +1,77 @@ +#!/usr/bin/env python +################################################## +# Gnuradio Python Flow Graph +# Title: Filter Test +# Generated: Mon Jan 14 01:39:57 2013 +################################################## + +from gnuradio import blks2 +from gnuradio import filter +from gnuradio import eng_notation +from gnuradio import gr +from gnuradio.eng_option import eng_option +from gnuradio.gr import firdes +from optparse import OptionParser + +class filter_test(gr.top_block): + + def __init__(self, num=1e7, which=''): + gr.top_block.__init__(self, "Filter Test") + + ################################################## + # Parameters + ################################################## + self.num = num + + ################################################## + # Variables + ################################################## + self.samp_rate = samp_rate = 32000 + + ################################################## + # Blocks + ################################################## + self.gr_null_source_0 = gr.null_source(gr.sizeof_gr_complex*1) + self.gr_null_sink_0 = gr.null_sink(gr.sizeof_gr_complex*1) + self.gr_head_0 = gr.head(gr.sizeof_gr_complex*1, int(num)) + self.blks2_rational_resampler_xxx_0 = blks2.rational_resampler_ccc( + interpolation=3, + decimation=7, + taps=None, + fractional_bw=None, + ) + self.fir_filter_xxx_0 = filter.fir_filter_ccc(7, ([.7]*23)) + + if which == 'dfir': self.filter = self.fir_filter_xxx_0 + if which == 'resamp': self.filter = self.blks2_rational_resampler_xxx_0 + + ################################################## + # Connections + ################################################## + self.connect((self.filter, 0), (self.gr_null_sink_0, 0)) + self.connect((self.gr_null_source_0, 0), (self.gr_head_0, 0)) + self.connect((self.gr_head_0, 0), (self.filter, 0)) + +# QT sink close method reimplementation + + def get_num(self): + return self.num + + def set_num(self, num): + self.num = num + + def get_samp_rate(self): + return self.samp_rate + + def set_samp_rate(self, samp_rate): + self.samp_rate = samp_rate + +if __name__ == '__main__': + parser = OptionParser(option_class=eng_option, usage="%prog: [options]") + parser.add_option("", "--num", dest="num", type="eng_float", default=eng_notation.num_to_str(1e7), + help="Set num [default=%default]") + parser.add_option("", "--which", dest="which", type="string", default='') + (options, args) = parser.parse_args() + tb = filter_test(num=options.num, which=options.which) + tb.run() + diff --git a/benchmark/tb_grextras_delay.py b/benchmark/tb_grextras_delay.py new file mode 100644 index 0000000..815ab3d --- /dev/null +++ b/benchmark/tb_grextras_delay.py @@ -0,0 +1,25 @@ +import gras +import grextras +import gnuradio +from gnuradio import gr +import sys + +if __name__ == '__main__': + + num = long(float(sys.argv[1])) + what = sys.argv[2] + + tb = gras.TopBlock() + src0 = gr.null_source(8) + sink = gr.null_sink(8) + head = gr.head(8, num) + + if what == 'extras_delay': delay_block = grextras.Delay(8) + if what == 'core_delay': delay_block = gr.delay(8, 0) + delay_block.set_delay(1000) + + tb.connect(src0, (delay_block, 0)) + tb.connect(delay_block, head, sink) + + tb.run() + tb.wait() |