# Profile until buffer is full

**URL:** <https://discourse.julialang.org/t/profile-until-buffer-is-full/60480>\
**Category:** Performance\
**Tags:** profiling\
**Created:** [May 3, 2021, 6:36pm UTC](https://discourse.julialang.org/t/profile-until-buffer-is-full/60480 "2021-05-03T18:36:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![goretkin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/goretkin/32/167_2.png) [@goretkin](https://discourse.julialang.org/u/goretkin)\
**Post date:** [May 3, 2021, 6:36pm UTC](https://discourse.julialang.org/t/profile-until-buffer-is-full/60480/1 "2021-05-03T18:36:36Z")

</div>

```julia
function busy(n)
    a = 0.0
    for i = 1:n
        a += sin(i)
        a += cos(a)
    end
    a
end

import Profile
Profile.init(; n=5000, delay=0.001)
Profile.@profile busy(10^7)
Profile.fetch()

```

shows that the buffer got full during profiling.

Is there a way to run e.g. `Profile.@profile busy(10^8)` but only until the profile buffer is full?

---

<div class="post-metadata">

**Author:** ![kimikage](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kimikage/32/14534_2.png) [@kimikage](https://discourse.julialang.org/u/kimikage)\
**Post date:** [May 5, 2021, 5:45am UTC](https://discourse.julialang.org/t/profile-until-buffer-is-full/60480/2 "2021-05-05T05:45:09Z")

</div>

I’ve added `is_buffer_full()`.  
[https://github.com/JuliaLang/julia/blob/f806df603489cfca558f6284d52a38f523b81881/stdlib/Profile/src/Profile.jl#L356](https://github.com/JuliaLang/julia/blob/f806df603489cfca558f6284d52a38f523b81881/stdlib/Profile/src/Profile.jl#L356)

However, as you can imagine, if you embed the check (inside the loop), it becomes noise.

I do not understand the purpose, but I think it is better to simply set a timeout.
