# See usage of Channel (i.e. how many items are enqueued)

**URL:** https://discourse.julialang.org/t/see-usage-of-channel-i-e-how-many-items-are-enqueued/69284
**Category:** General Usage
**Tags:** task, channel
**Created:** [October 6, 2021, 8:33am UTC](https://discourse.julialang.org/t/see-usage-of-channel-i-e-how-many-items-are-enqueued/69284 "2021-10-06T08:33:58Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![torrance](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/torrance/32/38990_2.png) [@torrance](https://discourse.julialang.org/u/torrance)
#### Post date: [October 6, 2021, 8:33am UTC](https://discourse.julialang.org/t/see-usage-of-channel-i-e-how-many-items-are-enqueued/69284/1 "2021-10-06T08:33:59Z")

</div>

I am using buffered Channels as a stream between different parts of my program, and I’d like to regularly find out how much of a buffered channel is actually used.

For example, if the channel is regularly empty, I know the producing task is a bottleneck, and if it is regularly full, I’ll know the consuming task is the bottleneck.

isready() is the closest I’ve come to getting information on this, but this can only tell me if the channel is empty. Is there a better way to do this?

---

<div class="post-metadata">

### Author: ![torrance](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/torrance/32/38990_2.png) [@torrance](https://discourse.julialang.org/u/torrance)
#### Post date: [October 6, 2021, 8:42am UTC](https://discourse.julialang.org/t/see-usage-of-channel-i-e-how-many-items-are-enqueued/69284/2 "2021-10-06T08:42:53Z")

</div>

And to immediately answer my own question:

To get a fraction of the channel used, try:

> length(ch.data) / ch.sz\_max

There’s probably issues with threadsafety when accessing the length(ch.data), but it’s good enough for my use case.

---

<div class="post-metadata">

### Author: ![Gnimuc](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gnimuc/32/2194_2.png) [@Gnimuc](https://discourse.julialang.org/u/Gnimuc)
#### Post date: [October 6, 2021, 11:09am UTC](https://discourse.julialang.org/t/see-usage-of-channel-i-e-how-many-items-are-enqueued/69284/3 "2021-10-06T11:09:37Z")

</div>

There is a non-exported function `Base.n_avail` for querying the length of current data. It works for both buffered and unbuffered channels.
