#!/usr/sbin/dtrace -s
/* David Leadbeater, 2011.
 * Time the match op.
 */

dtrace:::BEGIN {
  depth = 0
}

perl$target:::sub-entry
{
  self->sub = copyinstr(arg0);
  self->file = copyinstr(arg1);

  sdepth[depth] = self->sub;
  fdepth[depth++] = self->file;
}

perl$target:::sub-return
{
  self->sub = sdepth[--depth];
  self->file = fdepth[depth];
}

pid$target::Perl_pp_match:entry
{
  this->start = vtimestamp
}

pid$target::Perl_pp_match:return
{
  /*@[self->file, self->sub] = lquantize(vtimestamp - this->start, 0, 1000000, 65535)*/
  @[self->file, self->sub] = quantize(vtimestamp - this->start)
  /*@[1] = quantize(vtimestamp - this->start)*/
}

