This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Dealing with empty aggregates?


On Thu, 2011-05-19 at 15:46 +0100, Bryn M. Reeves wrote:
> On 05/19/2011 03:36 PM, Frank Ch. Eigler wrote:
> > The canonical construct doesn't require a hand-maintained flag:
> > 
> > probe timer.ms(1000) {
> >     if (@count(stuff))
> >        printf("Sum of stuff: %d\n", @sum(stuff))
> >     else
> >        printf("No stuff.")
> > }
> 
> Exactly what I was looking for, thanks! A count is not especially useful for the
> stuff I'm looking at (nfsd operations fwiw) and it didn't occur to me to gate on
> count (obvious really since it's the only one defined on an empty aggregate.. duh!).
> 
> Cheers,
> Bryn.

Another way: If all you're interested in is the sum, then you can
initialize it with
	stuff <<< 0
and then it'll never be empty.

Jim


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]