[lttng-dev] Measure loop rate

Jonathan Rajotte-Julien jonathan.rajotte-julien at efficios.com
Thu Jan 23 14:53:01 EST 2020


Hi,

On Wed, Jan 22, 2020 at 06:28:14PM +0100, bhanu kiran chaluvadi wrote:
> Hi ,
> 
> I am trying to observer loop rate of a while loop.  Ideally it should take
> maximum of 2 ms to finish the cycle (500 Hz at least). And i would like to
> trace the loop rate using LTTng user space. whats the better way of doing
> it ..Just place one trace point at the start and one at the end ? or is
> there any library that i can take advantage of?

I'm not completely sure what you mean by "loop rate" but if you are looking for
the duration of a single iteration of your while loop then yes, one at the start
and one at the end. Keep in mind that tracing is *not* free and that you will
need to account for the tracing overhead here. I would suggest having no payload
at all if you can.

There is other ways of deducing the time taken by one iteration (time_for_n/n)
to reduce impact of tracing if you can have an upper bound (or know the number
of iterations that took place) for the number of iterations but it will only
give you the mean time for the loop execution. In that case, the tracepoints
would be outside the while loop.

You could also hit an event only each X loop iterations and deduce the
rate from there. Keep in mind that this will require accounting and
will add to the workload etc.

It all depends on the granularity you are looking for.

Cheers
-- 
Jonathan Rajotte-Julien
EfficiOS


More information about the lttng-dev mailing list