# Performance diff between Null Sink & Copy Block

**URL:** <https://www.ruby-forum.com/t/performance-diff-between-null-sink-copy-block/234217>\
**Category:** GNU Radio\
**Created:** [February 16, 2015, 9:18pm UTC](https://www.ruby-forum.com/t/performance-diff-between-null-sink-copy-block/234217 "2015-02-16T21:18:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![addis\_a](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c4cdca/32.png) [@addis\_a](https://www.ruby-forum.com/u/addis_a)\
**Post date:** [February 16, 2015, 9:18pm UTC](https://www.ruby-forum.com/t/performance-diff-between-null-sink-copy-block/234217/1 "2015-02-16T21:18:50Z")

</div>

Hi - I am trying to create optional paths in my Gnuradio Flowgraph. I  
have found 2 ways of doing this in C++:

- Doing a lock() / unlock() inside my heir\_block2 and either connecting  
the items inside the block to the source of the block or connecting the  
source of the block to a null\_sink.
- Putting a gr::blocks::copy inside my heir\_block2 and either enabling  
or disabling when I want samples to go through the block.

With the null\_sink I get almost no CPU load when the source is connect  
to the Null Sink. However with the Copy block I get a decent amount of  
CPU load when the block is set to disable.

I looked at the code and looks like a Copy Block set to disable is about  
the same as a Null Sink. they both just do nothing with the incoming  
samples.

Why is the Copy Block using so much more CPU? Is it possible for it to  
have the same CPU load as a null sink?

Is there are better way of doing this? Should I write a custom block?

Thanks,

Luke

---

<div class="post-metadata">

**Author:** ![hagus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/9de053/32.png) [@hagus](https://www.ruby-forum.com/u/hagus)\
**Post date:** [February 16, 2015, 9:45pm UTC](https://www.ruby-forum.com/t/performance-diff-between-null-sink-copy-block/234217/2 "2015-02-16T21:45:04Z")

</div>

On 02/16/2015 09:17 PM, Luke B. wrote:

> amount of CPU load when the block is set to disable.
> 
> I looked at the code and looks like a Copy Block set to disable is  
> about the same as a Null Sink. they both just do nothing with the  
> incoming samples.
> 
> Why is the Copy Block using so much more CPU? Is it possible for it  
> to have the same CPU load as a null sink?

In the case of the copy block, the scheduler has no way of knowing that  
you’re treating it like a sink. That might explain the difference.

> Is there are better way of doing this? Should I write a custom  
> block?

Are you using GRC? If so, there’s the ‘Selector’, but I’m not sure if  
that does a better job than what you have. Depending on your signal  
setup, you might be able to use a matrix\_multiply, but that might make  
things worse CPU-wise.

M
