Bug 1569515 - Show overhead stats in Profiler tests - r=canaltinova

cppunittest TestBaseProfiler and gtest GeckoProfiler.Markers now show overhead
stats.
(Separate patch, because we may want to remove them after a while.)

Differential Revision: https://phabricator.services.mozilla.com/D39642

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Gerald Squelart 2019-07-31 01:28:53 +00:00
parent ce889db273
commit a8ae8a7a30
2 changed files with 62 additions and 0 deletions

View File

@ -936,6 +936,39 @@ void TestProfiler() {
SleepMilli(1000);
}
Maybe<baseprofiler::ProfilerBufferInfo> info =
baseprofiler::profiler_get_buffer_info();
MOZ_RELEASE_ASSERT(info.isSome());
printf("Profiler buffer range: %llu .. %llu (%llu bytes)\n",
static_cast<unsigned long long>(info->mRangeStart),
static_cast<unsigned long long>(info->mRangeEnd),
// sizeof(ProfileBufferEntry) == 9
(static_cast<unsigned long long>(info->mRangeEnd) -
static_cast<unsigned long long>(info->mRangeStart)) *
9);
printf("Stats: min(ns) .. mean(ns) .. max(ns) [count]\n");
printf("- Intervals: %7.1f .. %7.1f .. %7.1f [%u]\n",
info->mIntervalsNs.min,
info->mIntervalsNs.sum / info->mIntervalsNs.n,
info->mIntervalsNs.max, info->mIntervalsNs.n);
printf("- Overheads: %7.1f .. %7.1f .. %7.1f [%u]\n",
info->mOverheadsNs.min,
info->mOverheadsNs.sum / info->mOverheadsNs.n,
info->mOverheadsNs.max, info->mOverheadsNs.n);
printf(" - Locking: %7.1f .. %7.1f .. %7.1f [%u]\n",
info->mLockingsNs.min, info->mLockingsNs.sum / info->mLockingsNs.n,
info->mLockingsNs.max, info->mLockingsNs.n);
printf(" - Clearning: %7.1f .. %7.1f .. %7.1f [%u]\n",
info->mCleaningsNs.min,
info->mCleaningsNs.sum / info->mCleaningsNs.n,
info->mCleaningsNs.max, info->mCleaningsNs.n);
printf(" - Counters: %7.1f .. %7.1f .. %7.1f [%u]\n",
info->mCountersNs.min, info->mCountersNs.sum / info->mCountersNs.n,
info->mCountersNs.max, info->mCountersNs.n);
printf(" - Threads: %7.1f .. %7.1f .. %7.1f [%u]\n",
info->mThreadsNs.min, info->mThreadsNs.sum / info->mThreadsNs.n,
info->mThreadsNs.max, info->mThreadsNs.n);
printf("baseprofiler_save_profile_to_file()...\n");
baseprofiler::profiler_save_profile_to_file("TestProfiler_profile.json");

View File

@ -545,6 +545,35 @@ TEST(GeckoProfiler, Markers)
ASSERT_TRUE(!strstr(profile.get(), longstr.get()));
ASSERT_TRUE(strstr(profile.get(), "(too long)"));
Maybe<ProfilerBufferInfo> info = profiler_get_buffer_info();
MOZ_RELEASE_ASSERT(info.isSome());
printf("Profiler buffer range: %llu .. %llu (%llu bytes)\n",
static_cast<unsigned long long>(info->mRangeStart),
static_cast<unsigned long long>(info->mRangeEnd),
// sizeof(ProfileBufferEntry) == 9
(static_cast<unsigned long long>(info->mRangeEnd) -
static_cast<unsigned long long>(info->mRangeStart)) *
9);
printf("Stats: min(ns) .. mean(ns) .. max(ns) [count]\n");
printf("- Intervals: %7.1f .. %7.1f .. %7.1f [%u]\n",
info->mIntervalsNs.min, info->mIntervalsNs.sum / info->mIntervalsNs.n,
info->mIntervalsNs.max, info->mIntervalsNs.n);
printf("- Overheads: %7.1f .. %7.1f .. %7.1f [%u]\n",
info->mOverheadsNs.min, info->mOverheadsNs.sum / info->mOverheadsNs.n,
info->mOverheadsNs.max, info->mOverheadsNs.n);
printf(" - Locking: %7.1f .. %7.1f .. %7.1f [%u]\n",
info->mLockingsNs.min, info->mLockingsNs.sum / info->mLockingsNs.n,
info->mLockingsNs.max, info->mLockingsNs.n);
printf(" - Clearning: %7.1f .. %7.1f .. %7.1f [%u]\n",
info->mCleaningsNs.min, info->mCleaningsNs.sum / info->mCleaningsNs.n,
info->mCleaningsNs.max, info->mCleaningsNs.n);
printf(" - Counters: %7.1f .. %7.1f .. %7.1f [%u]\n",
info->mCountersNs.min, info->mCountersNs.sum / info->mCountersNs.n,
info->mCountersNs.max, info->mCountersNs.n);
printf(" - Threads: %7.1f .. %7.1f .. %7.1f [%u]\n",
info->mThreadsNs.min, info->mThreadsNs.sum / info->mThreadsNs.n,
info->mThreadsNs.max, info->mThreadsNs.n);
profiler_stop();
// The GTestMarkerPayloads should have been destroyed.