On Mon, Aug 24, 2009 at 1:50 PM, Joel Reymont<joe...@gmail.com> wrote:
> I'm trying to calculate the run time of all the initializers in Firefox [1].
> I'm placing the initialization time by library into an aggregation but I
> also need the sum of all the values in the aggregation. Is there an easy way
> to achieve this with D?
>
> I tried using a static variable (see startup.d) but initializers are being
> run in different threads and they overwrite my global counter.
>

Why not just use a separate aggregation for this?  For example, in
this one clause, you could do this:

pid$target::ImageLoader??runInitializers*:return
/self->ts && self->lib != 0/
{
  this->delta = timestamp - self->ts;
  @initint = sum(this->delta / 1000000000);
  @initfrac = sum(this->delta % 1000000000);
  @int[self->lib] = sum(this->delta / 1000000000);
  @frac[self->lib] = sum(this->delta % 1000000000);
  self->lib = 0;
  self->ts = 0;
}

And then print the value with a printa() statement:

  printa("Static init: %...@u.%@03us for %s\n", @int, @frac);
  printa("Static initialization: %...@u.%@03us\n", @initint, @initfrac);

Chad
_______________________________________________
dtrace-discuss mailing list
dtrace-discuss@opensolaris.org

Reply via email to