Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(65)

Unified Diff: tools/memory_inspector/memory_inspector/core/backends.py

Issue 158993002: Add Android-backend to the memory_inspector (prerequisites). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update ps_ext prebuilt sha1 Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 {}
« no previous file with comments | « tools/memory_inspector/memory_inspector/backends/prebuilts_fetcher.py ('k') | tools/memory_inspector/prebuilts/README » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698