Esempio n. 1
0
std::string Timer::Show() {
  std::string ret;

  if (Counters().empty()) return ret;

  auto const url = g_context->getRequestUrl(75);
  folly::format(&ret, "\nJIT timers for {}\n", url);

  auto const header = "{:<40} | {:>15} {:>15} {:>15}\n";
  auto const row    = "{:<40} | {:>15} {:>13,}us {:>13,}ns\n";
  folly::format(&ret, header, "name", "count", "total time", "average time");
  folly::format(&ret, "{:-^40}-+{:-^48}\n", "", "");

  std::map<std::string, Counter> sorted(s_counters->begin(), s_counters->end());
  for (auto const& pair : sorted) {
    auto& name = pair.first;
    auto& counter = pair.second;

    folly::format(&ret, row, name, counter.count, counter.total / 1000,
                  counter.mean());
  }

  ret += '\n';
  return ret;
}
Esempio n. 2
0
void TracePC::UpdateObservedPCs() {
  auto Observe = [&](uintptr_t PC) {
    bool Inserted = ObservedPCs.insert(PC).second;
    if (Inserted && DoPrintNewPCs)
      PrintPC("\tNEW_PC: %p %F %L\n", "\tNEW_PC: %p\n", PC + 1);
  };
  if (NumPCsInPCTables) {
    if (NumInline8bitCounters == NumPCsInPCTables) {
      for (size_t i = 0; i < NumModulesWithInline8bitCounters; i++) {
        uint8_t *Beg = ModuleCounters[i].Start;
        size_t Size = ModuleCounters[i].Stop - Beg;
        assert(Size ==
               (size_t)(ModulePCTable[i].Stop - ModulePCTable[i].Start));
        for (size_t j = 0; j < Size; j++)
          if (Beg[j])
            Observe(ModulePCTable[i].Start[j]);
      }
    } else if (NumGuards == NumPCsInPCTables) {
      size_t GuardIdx = 1;
      for (size_t i = 0; i < NumModules; i++) {
        uint32_t *Beg = Modules[i].Start;
        size_t Size = Modules[i].Stop - Beg;
        assert(Size ==
               (size_t)(ModulePCTable[i].Stop - ModulePCTable[i].Start));
        for (size_t j = 0; j < Size; j++, GuardIdx++)
          if (Counters()[GuardIdx])
            Observe(ModulePCTable[i].Start[j]);
      }
    }
  }
  if (size_t NumClangCounters =
      ClangCountersEnd() - ClangCountersBegin()) {
    auto P = ClangCountersBegin();
    for (size_t Idx = 0; Idx < NumClangCounters; Idx++)
      if (P[Idx])
        Observe((uintptr_t)Idx);
  }
}