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

Unified Diff: tools/telemetry/telemetry/timeline/trace_event_importer_unittest.py

Issue 1553183002: [telemetry] Add support for composable process dumps in memory-infra (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Nits. Created 4 years, 11 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/telemetry/telemetry/timeline/trace_event_importer_unittest.py
diff --git a/tools/telemetry/telemetry/timeline/trace_event_importer_unittest.py b/tools/telemetry/telemetry/timeline/trace_event_importer_unittest.py
index f69960b9c6b90533d3d87c5995f1087acda50101..61ed53881527803db3705c1ec7596587f514ad14 100644
--- a/tools/telemetry/telemetry/timeline/trace_event_importer_unittest.py
+++ b/tools/telemetry/telemetry/timeline/trace_event_importer_unittest.py
@@ -1059,23 +1059,94 @@ class TraceEventTimelineImporterTest(unittest.TestCase):
'id': '1234ABCD'},
{'name': 'a', 'cat': 'b', 'ph': 'v', 'pid': 54, 'ts': 134,
'id': '1234ABCD'},
+ {'name': 'a', 'cat': 'b', 'ph': 'v', 'pid': 52, 'ts': 134,
+ 'id': '1234ABCD'},
{'name': 'a', 'cat': 'b', 'ph': 'v', 'pid': 52, 'ts': 245,
'id': '1234ABDF'},
{'name': 'a', 'cat': 'b', 'ph': 'v', 'pid': 54, 'ts': 256,
'id': '1234ABDF'},
+ {'name': 'a', 'cat': 'b', 'ph': 'v', 'pid': 52, 'ts': 256,
+ 'id': '1234ABDF'},
]
- expected = [['1234ABCD', 0, 11], ['1234ABDF', 122, 11]]
+ expected_processes = set([52, 54])
+ expected_results = [['1234ABCD', 0, 11], ['1234ABDF', 122, 11]]
trace_data = trace_data_module.TraceData(events)
m = timeline_model.TimelineModel(trace_data)
+ assert set(p.pid for p in m.GetAllProcesses()) == expected_processes
+
memory_dumps = list(m.IterGlobalMemoryDumps())
- self.assertEqual(len(expected), len(memory_dumps))
- for memory_dump, test_values in zip(memory_dumps, expected):
+ self.assertEqual(len(expected_results), len(memory_dumps))
+ for memory_dump, test_values in zip(memory_dumps, expected_results):
+ assert len(list(memory_dump.IterProcessMemoryDumps())) == len(
+ expected_processes)
dump_id, start, duration = test_values
self.assertEquals(dump_id, memory_dump.dump_id)
self.assertAlmostEqual(start / 1000.0, memory_dump.start)
self.assertAlmostEqual(duration / 1000.0, memory_dump.duration)
+ def testImportComposableMemoryDumpEvents(self):
perezju 2016/01/12 15:53:38 I still feel this is more complicated than it has
ssid 2016/01/12 17:13:18 True. I have added to the previous test and remove
perezju 2016/01/13 16:30:34 sgtm
+ events = [
+ {
+ 'name': 'a',
+ 'cat': 'b',
+ 'ph': 'v',
+ 'pid': 52,
+ 'ts': 123,
+ 'id': '123',
+ 'args': {
+ 'dumps': {
+ 'allocators': {
+ 'v8': {'attrs': {'size': {'units': 'bytes', 'value': '0xa'}}}
+ }
+ }
+ }
+ },
+ {
+ 'name': 'a',
+ 'cat': 'b',
+ 'ph': 'v',
+ 'pid': 54,
+ 'ts': 134,
+ 'id': '123',
+ 'args': {
+ 'dumps': {
+ 'allocators': {
+ 'v8': {'attrs': {'size': {'units': 'bytes', 'value': '0xc'}}}
+ },
+ 'process_mmaps': {'vm_regions': [{'mf': '', 'bs': {'pss': '0xd'}}]}
+ }
+ }
+ },
+ {
+ 'name': 'a',
+ 'cat': 'b',
+ 'ph': 'v',
+ 'pid': 52,
+ 'ts': 134,
+ 'id': '123',
+ 'args': {
+ 'dumps': {
+ 'process_mmaps': {'vm_regions': [{'mf': '', 'bs': {'pss': '0xb'}}]}
+ }
+ }
+ }
+ ]
+
+ expected = [[10, 11], [12, 13]]
+ trace_data = trace_data_module.TraceData(events)
+ m = timeline_model.TimelineModel(trace_data)
+ memory_dumps_iter = m.IterGlobalMemoryDumps()
+ process_dumps = list(next(memory_dumps_iter).IterProcessMemoryDumps())
+ assert len(process_dumps) == len(expected)
+ for process_dump, test_values in zip(process_dumps, expected):
+ v8_size, heap_size = test_values
+ assert process_dump.has_mmaps
+ assert process_dump.GetMemoryBucket('/Native heap').GetValue(
+ 'proportional_resident') == heap_size
+ assert process_dump.GetMemoryUsage()['allocator_v8'] == v8_size
+ assert not next(memory_dumps_iter, None)
+
def testImportOutOfOrderMemoryDumpEvents(self):
events = [
{'name': 'a', 'cat': 'b', 'ph': 'v', 'pid': 52, 'ts': 245,

Powered by Google App Engine
This is Rietveld 408576698