示例#1
0
void GeckoSampler::InplaceTick(TickSample* sample)
{
  ThreadProfile& currThreadProfile = *sample->threadProfile;

  currThreadProfile.addTag(ProfileEntry('T', currThreadProfile.ThreadId()));

  if (sample) {
    mozilla::TimeDuration delta = sample->timestamp - sStartTime;
    currThreadProfile.addTag(ProfileEntry('t', delta.ToMilliseconds()));
  }

  PseudoStack* stack = currThreadProfile.GetPseudoStack();

#if defined(USE_NS_STACKWALK) || defined(USE_EHABI_STACKWALK) || \
    defined(USE_LUL_STACKWALK)
  if (mUseStackWalk) {
    doNativeBacktrace(currThreadProfile, sample);
  } else {
    doSampleStackTrace(currThreadProfile, sample, mAddLeafAddresses);
  }
#else
  doSampleStackTrace(currThreadProfile, sample, mAddLeafAddresses);
#endif

  // Don't process the PeudoStack's markers if we're
  // synchronously sampling the current thread.
  if (!sample->isSamplingCurrentThread) {
    ProfilerMarkerLinkedList* pendingMarkersList = stack->getPendingMarkers();
    while (pendingMarkersList && pendingMarkersList->peek()) {
      ProfilerMarker* marker = pendingMarkersList->popHead();
      currThreadProfile.addStoredMarker(marker);
      currThreadProfile.addTag(ProfileEntry('m', marker));
    }
  }

#ifndef SPS_STANDALONE
  if (sample && currThreadProfile.GetThreadResponsiveness()->HasData()) {
    mozilla::TimeDuration delta = currThreadProfile.GetThreadResponsiveness()->GetUnresponsiveDuration(sample->timestamp);
    currThreadProfile.addTag(ProfileEntry('r', delta.ToMilliseconds()));
  }
#endif

  // rssMemory is equal to 0 when we are not recording.
  if (sample && sample->rssMemory != 0) {
    currThreadProfile.addTag(ProfileEntry('R', static_cast<double>(sample->rssMemory)));
  }

  // ussMemory is equal to 0 when we are not recording.
  if (sample && sample->ussMemory != 0) {
    currThreadProfile.addTag(ProfileEntry('U', static_cast<double>(sample->ussMemory)));
  }

#if defined(XP_WIN)
  if (mProfilePower) {
    mIntelPowerGadget->TakeSample();
    currThreadProfile.addTag(ProfileEntry('p', static_cast<double>(mIntelPowerGadget->GetTotalPackagePowerInWatts())));
  }
#endif

  if (sLastFrameNumber != sFrameNumber) {
    currThreadProfile.addTag(ProfileEntry('f', sFrameNumber));
    sLastFrameNumber = sFrameNumber;
  }
}
示例#2
0
void TableTicker::InplaceTick(TickSample* sample)
{
  ThreadProfile& currThreadProfile = *sample->threadProfile;

  PseudoStack* stack = currThreadProfile.GetPseudoStack();
  bool recordSample = true;

  /* Don't process the PeudoStack's markers or honour jankOnly if we're
     immediately sampling the current thread. */
  if (!sample->isSamplingCurrentThread) {
    // Marker(s) come before the sample
    ProfilerMarkerLinkedList* pendingMarkersList = stack->getPendingMarkers();
    while (pendingMarkersList && pendingMarkersList->peek()) {
      ProfilerMarker* marker = pendingMarkersList->popHead();
      stack->addStoredMarker(marker);
      currThreadProfile.addTag(ProfileEntry('m', marker));
    }
    stack->updateGeneration(currThreadProfile.GetGenerationID());

    if (mJankOnly) {
      // if we are on a different event we can discard any temporary samples
      // we've kept around
      if (sLastSampledEventGeneration != sCurrentEventGeneration) {
        // XXX: we also probably want to add an entry to the profile to help
        // distinguish which samples are part of the same event. That, or record
        // the event generation in each sample
        currThreadProfile.erase();
      }
      sLastSampledEventGeneration = sCurrentEventGeneration;

      recordSample = false;
      // only record the events when we have a we haven't seen a tracer event for 100ms
      if (!sLastTracerEvent.IsNull()) {
        TimeDuration delta = sample->timestamp - sLastTracerEvent;
        if (delta.ToMilliseconds() > 100.0) {
            recordSample = true;
        }
      }
    }
  }

#if defined(USE_NS_STACKWALK) || defined(USE_EHABI_STACKWALK)
  if (mUseStackWalk) {
    doNativeBacktrace(currThreadProfile, sample);
  } else {
    doSampleStackTrace(stack, currThreadProfile, mAddLeafAddresses ? sample : nullptr);
  }
#else
  doSampleStackTrace(stack, currThreadProfile, mAddLeafAddresses ? sample : nullptr);
#endif

  if (recordSample)
    currThreadProfile.flush();

  if (!sLastTracerEvent.IsNull() && sample && currThreadProfile.IsMainThread()) {
    TimeDuration delta = sample->timestamp - sLastTracerEvent;
    currThreadProfile.addTag(ProfileEntry('r', delta.ToMilliseconds()));
  }

  if (sample) {
    TimeDuration delta = sample->timestamp - sStartTime;
    currThreadProfile.addTag(ProfileEntry('t', delta.ToMilliseconds()));
  }

  if (sLastFrameNumber != sFrameNumber) {
    currThreadProfile.addTag(ProfileEntry('f', sFrameNumber));
    sLastFrameNumber = sFrameNumber;
  }
}
示例#3
0
void TableTicker::InplaceTick(TickSample* sample)
{
    ThreadProfile& currThreadProfile = *sample->threadProfile;

    PseudoStack* stack = currThreadProfile.GetPseudoStack();
    stack->updateGeneration(currThreadProfile.GetGenerationID());
    bool recordSample = true;
#if defined(XP_WIN)
    bool powerSample = false;
#endif

    /* Don't process the PeudoStack's markers or honour jankOnly if we're
       immediately sampling the current thread. */
    if (!sample->isSamplingCurrentThread) {
        // Marker(s) come before the sample
        ProfilerMarkerLinkedList* pendingMarkersList = stack->getPendingMarkers();
        while (pendingMarkersList && pendingMarkersList->peek()) {
            ProfilerMarker* marker = pendingMarkersList->popHead();
            stack->addStoredMarker(marker);
            currThreadProfile.addTag(ProfileEntry('m', marker));
        }

#if defined(XP_WIN)
        if (mProfilePower) {
            mIntelPowerGadget->TakeSample();
            powerSample = true;
        }
#endif

        if (mJankOnly) {
            // if we are on a different event we can discard any temporary samples
            // we've kept around
            if (sLastSampledEventGeneration != sCurrentEventGeneration) {
                // XXX: we also probably want to add an entry to the profile to help
                // distinguish which samples are part of the same event. That, or record
                // the event generation in each sample
                currThreadProfile.erase();
            }
            sLastSampledEventGeneration = sCurrentEventGeneration;

            recordSample = false;
            // only record the events when we have a we haven't seen a tracer event for 100ms
            if (!sLastTracerEvent.IsNull()) {
                mozilla::TimeDuration delta = sample->timestamp - sLastTracerEvent;
                if (delta.ToMilliseconds() > 100.0) {
                    recordSample = true;
                }
            }
        }
    }

#if defined(USE_NS_STACKWALK) || defined(USE_EHABI_STACKWALK)
    if (mUseStackWalk) {
        doNativeBacktrace(currThreadProfile, sample);
    } else {
        doSampleStackTrace(currThreadProfile, sample, mAddLeafAddresses);
    }
#else
    doSampleStackTrace(currThreadProfile, sample, mAddLeafAddresses);
#endif

    if (recordSample)
        currThreadProfile.flush();

    if (sample && currThreadProfile.GetThreadResponsiveness()->HasData()) {
        mozilla::TimeDuration delta = currThreadProfile.GetThreadResponsiveness()->GetUnresponsiveDuration(sample->timestamp);
        currThreadProfile.addTag(ProfileEntry('r', static_cast<float>(delta.ToMilliseconds())));
    }

    if (sample) {
        mozilla::TimeDuration delta = sample->timestamp - sStartTime;
        currThreadProfile.addTag(ProfileEntry('t', static_cast<float>(delta.ToMilliseconds())));
    }

    // rssMemory is equal to 0 when we are not recording.
    if (sample && sample->rssMemory != 0) {
        currThreadProfile.addTag(ProfileEntry('R', static_cast<float>(sample->rssMemory)));
    }

    // ussMemory is equal to 0 when we are not recording.
    if (sample && sample->ussMemory != 0) {
        currThreadProfile.addTag(ProfileEntry('U', static_cast<float>(sample->ussMemory)));
    }

#if defined(XP_WIN)
    if (powerSample) {
        currThreadProfile.addTag(ProfileEntry('p', static_cast<float>(mIntelPowerGadget->GetTotalPackagePowerInWatts())));
    }
#endif

    if (sLastFrameNumber != sFrameNumber) {
        currThreadProfile.addTag(ProfileEntry('f', sFrameNumber));
        sLastFrameNumber = sFrameNumber;
    }
}