mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-17 23:35:34 +00:00
Bug 1329600 - Capture CPU usage on Windows - r=canaltinova
Differential Revision: https://phabricator.services.mozilla.com/D99414
This commit is contained in:
parent
ecaf794c38
commit
6b6370fc4a
@ -105,8 +105,13 @@ class PlatformData {
|
||||
|
||||
HANDLE ProfiledThread() { return mProfiledThread; }
|
||||
|
||||
RunningTimes& PreviousThreadRunningTimesRef() {
|
||||
return mPreviousThreadRunningTimes;
|
||||
}
|
||||
|
||||
private:
|
||||
HANDLE mProfiledThread;
|
||||
RunningTimes mPreviousThreadRunningTimes;
|
||||
};
|
||||
|
||||
#if defined(USE_MOZ_STACK_WALK)
|
||||
@ -125,15 +130,29 @@ void Sampler::Disable(PSLockRef aLock) {}
|
||||
|
||||
static void StreamMetaPlatformSampleUnits(PSLockRef aLock,
|
||||
SpliceableJSONWriter& aWriter) {
|
||||
// TODO
|
||||
aWriter.StringProperty("threadCPUDelta", "variable CPU cycles");
|
||||
}
|
||||
|
||||
static RunningTimes GetThreadRunningTimesDiff(
|
||||
PSLockRef aLock, const RegisteredThread& aRegisteredThread) {
|
||||
RunningTimes diff;
|
||||
AUTO_PROFILER_STATS(GetRunningTimes);
|
||||
|
||||
// TODO
|
||||
PlatformData* platformData = aRegisteredThread.GetPlatformData();
|
||||
MOZ_RELEASE_ASSERT(platformData);
|
||||
HANDLE profiledThread = platformData->ProfiledThread();
|
||||
|
||||
RunningTimes newRunningTimes;
|
||||
|
||||
{
|
||||
AUTO_PROFILER_STATS(GetRunningTimes_QueryThreadCycleTime);
|
||||
if (ULONG64 cycles; QueryThreadCycleTime(profiledThread, &cycles) != 0) {
|
||||
newRunningTimes.SetThreadCPUDelta(cycles);
|
||||
}
|
||||
}
|
||||
|
||||
RunningTimes diff =
|
||||
newRunningTimes - platformData->PreviousThreadRunningTimesRef();
|
||||
platformData->PreviousThreadRunningTimesRef() = newRunningTimes;
|
||||
return diff;
|
||||
}
|
||||
|
||||
|
@ -2220,6 +2220,14 @@ TEST(GeckoProfiler, CPUUsage)
|
||||
{
|
||||
EXPECT_EQ_JSON(sampleUnits["time"], String, "ms");
|
||||
EXPECT_EQ_JSON(sampleUnits["eventDelay"], String, "ms");
|
||||
#if defined(GP_OS_windows)
|
||||
// Note: The exact string is not important here.
|
||||
EXPECT_TRUE(sampleUnits["threadCPUDelta"].isString())
|
||||
<< "There should be a sampleUnits.threadCPUDelta on this platform";
|
||||
#else
|
||||
EXPECT_FALSE(sampleUnits.isMember("threadCPUDelta"))
|
||||
<< "Unexpected sampleUnits.threadCPUDelta on this platform";;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@ -2250,10 +2258,14 @@ TEST(GeckoProfiler, CPUUsage)
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(GP_OS_windows)
|
||||
EXPECT_GE(threadCPUDeltaCount, data.size() - 1u)
|
||||
<< "There should be 'threadCPUDelta' values in all but 1 samples";
|
||||
#else
|
||||
// All "threadCPUDelta" data should be absent or null on unsupported
|
||||
// platforms.
|
||||
// TODO: Update this test on supported platforms.
|
||||
EXPECT_EQ(threadCPUDeltaCount, 0u);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user