Fix CPU usage diagnostic logging in PerActivityStateCPUUsageSampler
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 27 Jan 2017 00:14:50 +0000 (00:14 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 27 Jan 2017 00:14:50 +0000 (00:14 +0000)
https://bugs.webkit.org/show_bug.cgi?id=167471
<rdar://problem/30221723>

Reviewed by Alex Christensen.

Fix CPU usage diagnostic logging in PerActivityStateCPUUsageSampler
to use numeric values for logDiagnosticMessageWithValue().

* UIProcess/PerActivityStateCPUUsageSampler.cpp:
(WebKit::PerActivityStateCPUUsageSampler::loggingTimerFired):
(WebKit::loggingKeyForCPUUsage): Deleted.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@211239 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/PerActivityStateCPUUsageSampler.cpp

index 111397e..909123a 100644 (file)
@@ -1,3 +1,18 @@
+2017-01-26  Chris Dumez  <cdumez@apple.com>
+
+        Fix CPU usage diagnostic logging in PerActivityStateCPUUsageSampler
+        https://bugs.webkit.org/show_bug.cgi?id=167471
+        <rdar://problem/30221723>
+
+        Reviewed by Alex Christensen.
+
+        Fix CPU usage diagnostic logging in PerActivityStateCPUUsageSampler
+        to use numeric values for logDiagnosticMessageWithValue().
+
+        * UIProcess/PerActivityStateCPUUsageSampler.cpp:
+        (WebKit::PerActivityStateCPUUsageSampler::loggingTimerFired):
+        (WebKit::loggingKeyForCPUUsage): Deleted.
+
 2017-01-26  Jeremy Jones  <jeremyj@apple.com>
 
         Request pointer unlock on navigation and re-enable pointer-lock tests for WK2.
index 2437e97..336603a 100644 (file)
@@ -70,17 +70,6 @@ static inline String loggingKeyForActivityState(ActivityStateForCPUSampling stat
     }
 }
 
-static inline String loggingKeyForCPUUsage(ActivityStateForCPUSampling state, double cpuUsage)
-{
-    switch (state) {
-    case ActivityStateForCPUSampling::NonVisible:
-        return DiagnosticLoggingKeys::backgroundCPUUsageToDiagnosticLoggingKey(cpuUsage);
-    case ActivityStateForCPUSampling::VisibleNonActive:
-    case ActivityStateForCPUSampling::VisibleAndActive:
-        return DiagnosticLoggingKeys::foregroundCPUUsageToDiagnosticLoggingKey(cpuUsage);
-    }
-}
-
 void PerActivityStateCPUUsageSampler::loggingTimerFired()
 {
     auto* page = pageForLogging();
@@ -94,9 +83,9 @@ void PerActivityStateCPUUsageSampler::loggingTimerFired()
 
     for (auto& pair : m_cpuTimeInActivityState) {
         double cpuUsage = static_cast<double>(pair.value * 100.) / cpuTimeDelta;
-        String loggingKey = loggingKeyForActivityState(pair.key);
-        page->logDiagnosticMessageWithValue(DiagnosticLoggingKeys::cpuUsageKey(), loggingKey, loggingKeyForCPUUsage(pair.key, cpuUsage), false);
-        RELEASE_LOG(PerformanceLogging, "WebContent processes used %.1f%% CPU in %s state", cpuUsage, loggingKey.utf8().data());
+        String activityStateKey = loggingKeyForActivityState(pair.key);
+        page->logDiagnosticMessageWithValue(DiagnosticLoggingKeys::cpuUsageKey(), activityStateKey, String::number(cpuUsage, 1), false);
+        RELEASE_LOG(PerformanceLogging, "WebContent processes used %.1f%% CPU in %s state", cpuUsage, activityStateKey.utf8().data());
     }
 
     m_cpuTimeInActivityState.clear();