diff options
-rw-r--r-- | benchmark/bm_registry.py | 41 | ||||
-rw-r--r-- | benchmark/run_benchmarks.py | 34 | ||||
-rw-r--r-- | benchmark/tb_filter_block.py | 24 | ||||
-rw-r--r-- | benchmark/tb_grextras_delay.py | 14 | ||||
-rw-r--r-- | benchmark/tb_grextras_math.py | 14 | ||||
-rw-r--r-- | benchmark/tb_many_1_to_1_blocks.py | 14 | ||||
-rw-r--r-- | benchmark/tb_many_rate_changes.py | 24 | ||||
m--------- | gnuradio | 0 |
8 files changed, 87 insertions, 78 deletions
diff --git a/benchmark/bm_registry.py b/benchmark/bm_registry.py index bb9c0cc..7c9bb1c 100644 --- a/benchmark/bm_registry.py +++ b/benchmark/bm_registry.py @@ -6,6 +6,8 @@ def tokwargs(**kwargs): return kwargs INSTALL_PREFIX = '/opt/usr' +DURATION = '1.7' #seconds + GRAS_ENV = { 'PATH': os.path.join(INSTALL_PREFIX, 'gras/bin:$PATH:%s'%os.getenv('PATH')), 'LD_LIBRARY_PATH': os.path.join(INSTALL_PREFIX, 'gras/lib:%s'%os.getenv('LD_LIBRARY_PATH')), @@ -25,10 +27,9 @@ BENCHMARK_MANY_11_BLOCKS = tokwargs( - GRAS will use only the buffer pool allocator, and every work will fully consume available buffers.''', tests = [ - tokwargs(wat='GRAS', args=['tb_many_1_to_1_blocks.py', '1e8'], env=GRAS_ENV), - tokwargs(wat='GR', args=['tb_many_1_to_1_blocks.py', '1e8'], env=GR_ENV), + tokwargs(wat='GRAS', args=['tb_many_1_to_1_blocks.py', DURATION], env=GRAS_ENV), + tokwargs(wat='GR', args=['tb_many_1_to_1_blocks.py', DURATION], env=GR_ENV), ], - to_result = lambda t: 1e8/t ) BENCHMARK_MANY_RATE_BLOCKS = tokwargs( @@ -38,10 +39,9 @@ BENCHMARK_MANY_RATE_BLOCKS = tokwargs( - GRAS will use only the buffer pool allocator, and every work will fully consume available buffers.''', tests = [ - tokwargs(wat='GRAS', args=['tb_many_rate_changes.py', '1e4'], env=GRAS_ENV), - tokwargs(wat='GR', args=['tb_many_rate_changes.py', '1e4'], env=GR_ENV), + tokwargs(wat='GRAS', args=['tb_many_rate_changes.py', '--dur', DURATION], env=GRAS_ENV), + tokwargs(wat='GR', args=['tb_many_rate_changes.py', '--dur', DURATION], env=GR_ENV), ], - to_result = lambda t: 1e4/t ) BENCHMARK_FILTER_BLOCK = tokwargs( @@ -52,12 +52,11 @@ BENCHMARK_FILTER_BLOCK = tokwargs( - The decimating FIR filter is compared. - The rational resampler filter is compared.''', 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), + tokwargs(wat='GRAS decim FIR', args=['tb_filter_block.py', '--dur', DURATION, '--which', 'dfir'], env=GRAS_ENV), + tokwargs(wat='GR decim FIR', args=['tb_filter_block.py', '--dur', DURATION, '--which', 'dfir'], env=GR_ENV), + tokwargs(wat='GRAS resampler', args=['tb_filter_block.py', '--dur', DURATION, '--which', 'resamp'], env=GRAS_ENV), + tokwargs(wat='GR resampler', args=['tb_filter_block.py', '--dur', DURATION, '--which', 'resamp'], env=GR_ENV), ], - to_result = lambda t: 1e7/t ) BENCHMARK_MATH_OPS = tokwargs( @@ -68,14 +67,13 @@ BENCHMARK_MATH_OPS = tokwargs( - GrExtras math blocks avoid an unnecessary memcpy. - GrExtras math blocks enable automatic bufer in-placing.''', tests = [ - tokwargs(wat='GrExtras Add\n(GRAS)', args=['tb_grextras_math.py', '1e8', 'extras_add'], env=GRAS_ENV), - tokwargs(wat='gr-blocks Add\n(GRAS)', args=['tb_grextras_math.py', '1e8', 'blocks_add'], env=GRAS_ENV), - tokwargs(wat='gr-blocks Add\n(GR)', args=['tb_grextras_math.py', '1e8', 'blocks_add'], env=GR_ENV), - tokwargs(wat='GrExtras Mult\n(GRAS)', args=['tb_grextras_math.py', '1e8', 'extras_mult'], env=GRAS_ENV), - tokwargs(wat='gr-blocks Mult\n(GRAS)', args=['tb_grextras_math.py', '1e8', 'blocks_mult'], env=GRAS_ENV), - tokwargs(wat='gr-blocks Mult\n(GR)', args=['tb_grextras_math.py', '1e8', 'blocks_mult'], env=GR_ENV), + tokwargs(wat='GrExtras Add\n(GRAS)', args=['tb_grextras_math.py', DURATION, 'extras_add'], env=GRAS_ENV), + tokwargs(wat='gr-blocks Add\n(GRAS)', args=['tb_grextras_math.py', DURATION, 'blocks_add'], env=GRAS_ENV), + tokwargs(wat='gr-blocks Add\n(GR)', args=['tb_grextras_math.py', DURATION, 'blocks_add'], env=GR_ENV), + tokwargs(wat='GrExtras Mult\n(GRAS)', args=['tb_grextras_math.py', DURATION, 'extras_mult'], env=GRAS_ENV), + tokwargs(wat='gr-blocks Mult\n(GRAS)', args=['tb_grextras_math.py', DURATION, 'blocks_mult'], env=GRAS_ENV), + tokwargs(wat='gr-blocks Mult\n(GR)', args=['tb_grextras_math.py', DURATION, 'blocks_mult'], env=GR_ENV), ], - to_result = lambda t: 1e8/t ) BENCHMARK_DELAY_BLOCKS = tokwargs( @@ -84,11 +82,10 @@ BENCHMARK_DELAY_BLOCKS = tokwargs( - Compare delay block implementations using GRAS. - The GrExtras implementation uses zero-copy.''', tests = [ - tokwargs(wat='GrExtras Delay\n(GRAS)', args=['tb_grextras_delay.py', '1e8', 'extras_delay'], env=GRAS_ENV), - tokwargs(wat='gr-core Delay\n(GRAS)', args=['tb_grextras_delay.py', '1e8', 'core_delay'], env=GRAS_ENV), - tokwargs(wat='gr-core Delay\n(GR)', args=['tb_grextras_delay.py', '1e8', 'core_delay'], env=GR_ENV), + tokwargs(wat='GrExtras Delay\n(GRAS)', args=['tb_grextras_delay.py', DURATION, 'extras_delay'], env=GRAS_ENV), + tokwargs(wat='gr-core Delay\n(GRAS)', args=['tb_grextras_delay.py', DURATION, 'core_delay'], env=GRAS_ENV), + tokwargs(wat='gr-core Delay\n(GR)', args=['tb_grextras_delay.py', DURATION, 'core_delay'], env=GR_ENV), ], - to_result = lambda t: 1e8/t ) BENCHMARKS = ( diff --git a/benchmark/run_benchmarks.py b/benchmark/run_benchmarks.py index 3aa04ec..8cb3503 100644 --- a/benchmark/run_benchmarks.py +++ b/benchmark/run_benchmarks.py @@ -17,18 +17,32 @@ from bm_registry import BENCHMARKS NUM_RUNS_PER_TEST = 5 +BAD_BOOST_KILL_DURATION = 5.0 #seconds + __path__ = os.path.dirname(__file__) -def time_a_single_one(args, env): +import threading + +#because boost interrupts are broken in half the versions of boost +#this stupidity makes stock gnuradio apps exit with bad boost +def kill_after_timeout(p): + time.sleep(BAD_BOOST_KILL_DURATION) + try: p.kill() + except: pass + +def run_a_single_one(args, env): print env - t0 = time.time() p = subprocess.Popen(args=args, env=env, stdout=subprocess.PIPE) + t = threading.Thread(target=kill_after_timeout, args = (p,)) + t.daemon = True + t.start() p.wait() - t1 = time.time() - for line in p.stdout.read().splitlines(): - if line.startswith('#/#/'): - return float(line[4:].strip()) - raise Exception, 'no time result found!' + out = p.stdout.read() + #print out + for line in out.splitlines(): + if line.startswith('##RESULT##'): + return float(line[len('##RESULT##'):].strip()) + raise Exception, 'no result found!' #return t1-t0 def do_a_benchmark(bm): @@ -54,9 +68,9 @@ def do_a_benchmark(bm): env.update(run['envextra']) run_results = list() for num_runs in range(NUM_RUNS_PER_TEST): - t = time_a_single_one(args=args, env=env) - print 'execution time: ', t, 'secs' - run_results.append(bm['to_result'](t)) + res = run_a_single_one(args=args, env=env) + print 'Result:', res + run_results.append(res) result_means.append(numpy.average(run_results)) result_stddevs.append(numpy.std(run_results)) diff --git a/benchmark/tb_filter_block.py b/benchmark/tb_filter_block.py index 3726a92..d07a64b 100644 --- a/benchmark/tb_filter_block.py +++ b/benchmark/tb_filter_block.py @@ -15,15 +15,10 @@ from optparse import OptionParser class filter_test(gr.top_block): - def __init__(self, num=1e7, which=''): + def __init__(self, which=''): gr.top_block.__init__(self, "Filter Test") ################################################## - # Parameters - ################################################## - self.num = num - - ################################################## # Variables ################################################## self.samp_rate = samp_rate = 32000 @@ -33,7 +28,6 @@ class filter_test(gr.top_block): ################################################## 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, @@ -49,8 +43,7 @@ class filter_test(gr.top_block): # 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)) + self.connect((self.gr_null_source_0, 0), (self.filter, 0)) # QT sink close method reimplementation @@ -68,13 +61,16 @@ class filter_test(gr.top_block): 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), + parser.add_option("", "--dur", dest="dur", type="eng_float", default=eng_notation.num_to_str(1.0), 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 = filter_test(which=options.which) import time - s = time.time() - tb.run() - print '#/#/',time.time() - s + tb.start() + time.sleep(options.dur) + print '##RESULT##', tb.gr_null_sink_0.nitems_read(0)/options.dur + import sys; sys.stdout.flush() + tb.stop() + tb.wait() diff --git a/benchmark/tb_grextras_delay.py b/benchmark/tb_grextras_delay.py index 2a68eb6..3ed05b4 100644 --- a/benchmark/tb_grextras_delay.py +++ b/benchmark/tb_grextras_delay.py @@ -8,22 +8,24 @@ import sys if __name__ == '__main__': - num = long(float(sys.argv[1])) + duration = float(sys.argv[1]) what = sys.argv[2] tb = gr.top_block() 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.connect(delay_block, sink) import time - s = time.time() - tb.run() - print '#/#/',time.time() - s + tb.start() + time.sleep(duration) + print '##RESULT##', sink.nitems_read(0)/duration + import sys; sys.stdout.flush() + tb.stop() + tb.wait() diff --git a/benchmark/tb_grextras_math.py b/benchmark/tb_grextras_math.py index 562608a..4f8d2ad 100644 --- a/benchmark/tb_grextras_math.py +++ b/benchmark/tb_grextras_math.py @@ -9,14 +9,13 @@ import sys if __name__ == '__main__': - num = long(float(sys.argv[1])) + duration = float(sys.argv[1]) what = sys.argv[2] tb = gr.top_block() src0 = gr.null_source(8) src1 = gr.null_source(8) sink = gr.null_sink(8) - head = gr.head(8, num) if what == 'extras_add': math_op = grextras.Add.fc32_fc32() if what == 'blocks_add': math_op = grblocks.add_cc() @@ -25,9 +24,12 @@ if __name__ == '__main__': tb.connect(src0, (math_op, 0)) tb.connect(src1, (math_op, 1)) - tb.connect(math_op, head, sink) + tb.connect(math_op, sink) import time - s = time.time() - tb.run() - print '#/#/',time.time() - s + tb.start() + time.sleep(duration) + print '##RESULT##', sink.nitems_read(0)/duration + import sys; sys.stdout.flush() + tb.stop() + tb.wait() diff --git a/benchmark/tb_many_1_to_1_blocks.py b/benchmark/tb_many_1_to_1_blocks.py index 7900ea5..c545d7e 100644 --- a/benchmark/tb_many_1_to_1_blocks.py +++ b/benchmark/tb_many_1_to_1_blocks.py @@ -5,7 +5,7 @@ import sys if __name__ == '__main__': - num = long(float(sys.argv[1])) + duration = float(sys.argv[1]) tb = gr.top_block() src0 = gr.null_source(8) @@ -16,7 +16,6 @@ if __name__ == '__main__': addr23 = grblocks.add_cc() mult03 = grblocks.multiply_cc() sink = gr.null_sink(8) - head = gr.head(8, num) tb.connect(src0, (addr01, 0)) tb.connect(src1, (addr01, 1)) @@ -26,9 +25,12 @@ if __name__ == '__main__': tb.connect(addr01, (mult03, 0)) tb.connect(addr23, (mult03, 1)) - tb.connect(mult03, head, sink) + tb.connect(mult03, sink) import time - s = time.time() - tb.run() - print '#/#/',time.time() - s + tb.start() + time.sleep(duration) + print '##RESULT##', sink.nitems_read(0)/duration + import sys; sys.stdout.flush() + tb.stop() + tb.wait() diff --git a/benchmark/tb_many_rate_changes.py b/benchmark/tb_many_rate_changes.py index 4f259b7..e94179f 100644 --- a/benchmark/tb_many_rate_changes.py +++ b/benchmark/tb_many_rate_changes.py @@ -15,15 +15,10 @@ import numpy class many_rate_changing(gr.top_block): - def __init__(self, num=1e7): + def __init__(self): gr.top_block.__init__(self, "Many Rate Changing") ################################################## - # Parameters - ################################################## - self.num = num - - ################################################## # Variables ################################################## self.samp_rate = samp_rate = 32000 @@ -35,7 +30,6 @@ class many_rate_changing(gr.top_block): self.gr_unpacked_to_packed_xx_0 = gr.unpacked_to_packed_bb(2, gr.GR_LSB_FIRST) self.gr_packed_to_unpacked_xx_0 = gr.packed_to_unpacked_bb(2, gr.GR_MSB_FIRST) self.gr_null_sink_0_2 = gr.null_sink(gr.sizeof_char*1) - self.gr_head_0 = gr.head(gr.sizeof_char*1, int(num)) self.blocks_keep_m_in_n_0 = blocks.keep_m_in_n(gr.sizeof_float, 3, 20, 0) self.blocks_float_to_char_0 = blocks.float_to_char(1, 1) self.blocks_char_to_float_0 = blocks.char_to_float(1, 1) @@ -48,8 +42,7 @@ class many_rate_changing(gr.top_block): self.connect((self.blocks_float_to_char_0, 0), (self.gr_packed_to_unpacked_xx_0, 0)) self.connect((self.gr_unpacked_to_packed_xx_0, 0), (self.blocks_char_to_float_0, 0)) self.connect((self.random_source_x_0, 0), (self.gr_unpacked_to_packed_xx_0, 0)) - self.connect((self.gr_packed_to_unpacked_xx_0, 0), (self.gr_head_0, 0)) - self.connect((self.gr_head_0, 0), (self.gr_null_sink_0_2, 0)) + self.connect((self.gr_packed_to_unpacked_xx_0, 0), (self.gr_null_sink_0_2, 0)) def get_num(self): @@ -66,12 +59,15 @@ class many_rate_changing(gr.top_block): 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), + parser.add_option("", "--dur", dest="dur", type="eng_float", default=eng_notation.num_to_str(1.0), help="Set num [default=%default]") (options, args) = parser.parse_args() - tb = many_rate_changing(num=options.num) + tb = many_rate_changing() import time - s = time.time() - tb.run() - print '#/#/',time.time() - s + tb.start() + time.sleep(options.dur) + print '##RESULT##', tb.gr_null_sink_0_2.nitems_read(0)/options.dur + import sys; sys.stdout.flush() + tb.stop() + tb.wait() diff --git a/gnuradio b/gnuradio -Subproject d99eb362def2c50c3c9b80c63c33f85df2babac +Subproject 563240c2b4efc26e6c4032b0d3d75fc5489b7f1 |