Profile until buffer is full

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

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

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?

I’ve added is_buffer_full().

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.