| Index: tools/memory_inspector/memory_inspector/core/backends.py
|
| diff --git a/tools/memory_inspector/memory_inspector/core/backends.py b/tools/memory_inspector/memory_inspector/core/backends.py
|
| index c5679ee30c3be680973626fbb102db97f4a869a7..b230dcb37cc20f0d23018807b5d2f32cefea5230 100644
|
| --- a/tools/memory_inspector/memory_inspector/core/backends.py
|
| +++ b/tools/memory_inspector/memory_inspector/core/backends.py
|
| @@ -37,7 +37,7 @@ def GetDevice(backend_name, device_id):
|
| class Backend(object):
|
| """Base class for backends.
|
|
|
| - This is the extension point for the OS-specific profiler implementations.
|
| + This is the extension point for the OS-specific profiler implementations.
|
| """
|
|
|
| def __init__(self, settings=None):
|
| @@ -68,6 +68,10 @@ class Device(object):
|
| # Initialize with empty settings if not required by the overriding device.
|
| self.settings = settings or Settings()
|
|
|
| + def Initialize(self):
|
| + """Called before anything else, for initial provisioning."""
|
| + raise NotImplementedError()
|
| +
|
| def IsNativeAllocTracingEnabled(self):
|
| """Check if the device is ready to capture native allocation traces."""
|
| raise NotImplementedError()
|
| @@ -92,6 +96,10 @@ class Device(object):
|
| """Returns an instance of |Process| or None (if not found)."""
|
| raise NotImplementedError()
|
|
|
| + def GetStats(self):
|
| + """Returns an instance of |DeviceStats|."""
|
| + raise NotImplementedError()
|
| +
|
| @property
|
| def name(self):
|
| """Friendly name of the target device (e.g., phone model)."""
|
| @@ -121,16 +129,54 @@ class Process(object):
|
| """Returns an instance of |native_heap.NativeHeap|."""
|
| raise NotImplementedError()
|
|
|
| + def GetStats(self):
|
| + """Returns an instance of |ProcessStats|."""
|
| + raise NotImplementedError()
|
| +
|
| def __str__(self):
|
| return '[%d] %s' % (self.pid, self.name)
|
|
|
|
|
| +class DeviceStats(object):
|
| + """CPU/Memory stats for a |Device|."""
|
| +
|
| + def __init__(self, uptime, cpu_times, memory_stats):
|
| + """Args:
|
| + uptime: uptime in seconds.
|
| + cpu_times: array (CPUs) of dicts (cpu times since last call).
|
| + e.g., [{'User': 10, 'System': 80, 'Idle': 10}, ... ]
|
| + memory_stats: Dictionary of memory stats. e.g., {'Free': 1, 'Cached': 10}
|
| + """
|
| + assert(isinstance(cpu_times, list) and isinstance(cpu_times[0], dict))
|
| + assert(isinstance(memory_stats, dict))
|
| + self.uptime = uptime
|
| + self.cpu_times = cpu_times
|
| + self.memory_stats = memory_stats
|
| +
|
| +
|
| +class ProcessStats(object):
|
| + """CPU/Memory stats for a |Process|."""
|
| +
|
| + def __init__(self, threads, run_time, cpu_usage, vm_rss, page_faults):
|
| + """Args:
|
| + threads: Number of threads.
|
| + run_time: Total process uptime in seconds.
|
| + cpu_usage: CPU usage [0-100] since the last GetStats call.
|
| + vm_rss_kb: Resident Memory Set in Kb.
|
| + page_faults: Number of VM page faults (hard + soft).
|
| + """
|
| + self.threads = threads
|
| + self.run_time = run_time
|
| + self.cpu_usage = cpu_usage
|
| + self.vm_rss = vm_rss
|
| + self.page_faults = page_faults
|
| +
|
| +
|
| class Settings(object):
|
| """Models user-definable settings for backends and devices."""
|
|
|
| def __init__(self, expected_keys=None):
|
| - """
|
| - Args:
|
| + """Args:
|
| expected_keys: A dict. (key-name -> description) of expected settings
|
| """
|
| self.expected_keys = expected_keys or {}
|
|
|