diff options
Diffstat (limited to 'chromium/third_party/catapult/tracing/tracing/model/memory_dump_test_utils.html')
-rw-r--r-- | chromium/third_party/catapult/tracing/tracing/model/memory_dump_test_utils.html | 92 |
1 files changed, 78 insertions, 14 deletions
diff --git a/chromium/third_party/catapult/tracing/tracing/model/memory_dump_test_utils.html b/chromium/third_party/catapult/tracing/tracing/model/memory_dump_test_utils.html index 55a499192bf..eaad055b4d3 100644 --- a/chromium/third_party/catapult/tracing/tracing/model/memory_dump_test_utils.html +++ b/chromium/third_party/catapult/tracing/tracing/model/memory_dump_test_utils.html @@ -5,13 +5,13 @@ Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. --> +<link rel="import" href="/tracing/base/unit.html"> <link rel="import" href="/tracing/model/container_memory_dump.html"> <link rel="import" href="/tracing/model/global_memory_dump.html"> <link rel="import" href="/tracing/model/memory_allocator_dump.html"> <link rel="import" href="/tracing/model/process_memory_dump.html"> <link rel="import" href="/tracing/model/vm_region.html"> <link rel="import" href="/tracing/value/numeric.html"> -<link rel="import" href="/tracing/value/unit.html"> <script> 'use strict'; @@ -28,7 +28,7 @@ tr.exportTo('tr.model', function() { var VMRegionClassificationNode = tr.model.VMRegionClassificationNode; var ScalarNumeric = tr.v.ScalarNumeric; var sizeInBytes_smallerIsBetter = - tr.v.Unit.byName.sizeInBytes_smallerIsBetter; + tr.b.Unit.byName.sizeInBytes_smallerIsBetter; var LIGHT = tr.model.ContainerMemoryDump.LevelOfDetail.LIGHT; function castToScalarNumeric(value) { @@ -38,22 +38,56 @@ tr.exportTo('tr.model', function() { return value; } + function getOption(opt_options, key, opt_defaultValue) { + if (opt_options && (key in opt_options)) + return opt_options[key]; + else + return opt_defaultValue; + } + function MemoryDumpTestUtils() { throw new Error('Static class'); } MemoryDumpTestUtils.SIZE_DELTA = 0.0001; - MemoryDumpTestUtils.addGlobalMemoryDump = function( - model, timestamp, opt_levelOfDetail) { + /** + * Create a new global memory dump and add it to a model. + * + * @param {!tr.Model} model The trace model to which the new global dump + * should be added. + * @param {!{ + * ts: (number|undefined), + * duration: (number|undefined), + * levelOfDetail: (!tr.model.ContainerMemoryDump.LevelOfDetail|undefined) + * }=} opt_options Options for creating the new global dump. + * @return {!tr.model.GlobalMemoryDump} The newly created global memory dump. + */ + MemoryDumpTestUtils.addGlobalMemoryDump = function(model, opt_options) { + var timestamp = getOption(opt_options, 'ts', 0); var gmd = new GlobalMemoryDump(model, timestamp); - gmd.levelOfDetail = opt_levelOfDetail === undefined ? - LIGHT : opt_levelOfDetail; + gmd.levelOfDetail = getOption(opt_options, 'levelOfDetail', LIGHT); + gmd.duration = getOption(opt_options, 'duration', 0); model.globalMemoryDumps.push(gmd); return gmd; }; - MemoryDumpTestUtils.addProcessMemoryDump = function(gmd, process, timestamp) { + /** + * Create a new process memory dump and add it to a global memory dump. + * + * @param {!tr.model.GlobalMemoryDump} gmd The global dump to which the new + * process dump should be added. + * @param {!tr.model.Process} pmd The process associated with the process + * dump. + * @param {!{ + * ts: (number|undefined) + * }=} opt_options Options for creating the new process dump. + * @return {!tr.model.ProcessMemoryDump} The newly created process memory + * dump. + */ + MemoryDumpTestUtils.addProcessMemoryDump = + function(gmd, process, opt_options) { + var timestamp = getOption(opt_options, 'ts', gmd.start); var pmd = new ProcessMemoryDump(gmd, process, timestamp); process.memoryDumps.push(pmd); if (process.pid in gmd.processMemoryDumps) { @@ -65,22 +99,52 @@ tr.exportTo('tr.model', function() { return pmd; }; + /** + * Create a new memory allocator dump. + * + * @param {!tr.model.ContainerMemoryDump} containerDump The container dump + * associated with the new allocator dump. + * @param {string} fullName The full name of the new allocator dump + * (including ancestors). + * @param {!{ + * guid: (number|undefined), + * numerics: (!Object<string, (number|!tr.v.ScalarNumeric)>|undefined) + * }=} opt_options Options for creating the new allocator dump. + * @return {!tr.model.MemoryAllocatorDump} The newly created memory allocator + * dump. + */ MemoryDumpTestUtils.newAllocatorDump = function( - containerDump, fullName, opt_numerics, opt_guid) { - var dump = new MemoryAllocatorDump(containerDump, fullName, opt_guid); - if (opt_numerics !== undefined) { - tr.b.iterItems(opt_numerics, function(numericName, value) { + containerDump, fullName, opt_options) { + var dump = new MemoryAllocatorDump(containerDump, fullName, + getOption(opt_options, 'guid')); + var numerics = getOption(opt_options, 'numerics'); + if (numerics) { + tr.b.iterItems(numerics, function(numericName, value) { dump.addNumeric(numericName, castToScalarNumeric(value)); }); } return dump; }; - MemoryDumpTestUtils.addChildDump = - function(parentDump, name, opt_numerics, opt_guid) { + /** + * Create a new child memory allocator dump and add it to a parent memory + * allocator dump. + * + * @param {!tr.model.MemoryAllocatorDump} parentDump The parent allocator + * dump. + * @param {string} name The name of the child allocator dump (excluding + * ancestors). + * @param {!{ + * guid: (number|undefined), + * numerics: (!Object<string, (number|!tr.v.ScalarNumeric)>|undefined) + * }=} opt_options Options for creating the child allocator dump. + * @return {!tr.model.MemoryAllocatorDump} The newly created child memory + * allocator dump. + */ + MemoryDumpTestUtils.addChildDump = function(parentDump, name, opt_options) { var childDump = MemoryDumpTestUtils.newAllocatorDump( parentDump.containerMemoryDump, parentDump.fullName + '/' + name, - opt_numerics, opt_guid); + opt_options); childDump.parent = parentDump; parentDump.children.push(childDump); return childDump; |