summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tools/telemetry/telemetry/core/platform/win_platform_backend.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/tools/telemetry/telemetry/core/platform/win_platform_backend.py b/tools/telemetry/telemetry/core/platform/win_platform_backend.py
index 144ed45..d3949cd 100644
--- a/tools/telemetry/telemetry/core/platform/win_platform_backend.py
+++ b/tools/telemetry/telemetry/core/platform/win_platform_backend.py
@@ -7,6 +7,7 @@ import ctypes
import os
import re
import subprocess
+import time
try:
import pywintypes # pylint: disable=F0401
import win32api # pylint: disable=F0401
@@ -72,6 +73,24 @@ class WinPlatformBackend(desktop_platform_backend.DesktopPlatformBackend):
ctypes.byref(performance_info), performance_info.size)
return performance_info.CommitTotal * performance_info.PageSize / 1024
+ def GetCpuStats(self, pid):
+ try:
+ cpu_info = win32process.GetProcessTimes(
+ self._GetProcessHandle(pid))
+ except pywintypes.error, e:
+ errcode = e[0]
+ if errcode == 87: # The process may have been closed.
+ return {}
+ raise
+ # Convert 100 nanosecond units to seconds
+ cpu_time = (cpu_info['UserTime'] / 1e7 +
+ cpu_info['KernelTime'] / 1e7)
+ return {'CpuProcessTime': cpu_time}
+
+ def GetCpuTimestamp(self):
+ """Return current timestamp in seconds."""
+ return {'TotalTime': time.time()}
+
def GetMemoryStats(self, pid):
try:
memory_info = win32process.GetProcessMemoryInfo(