blob: 669c7d51fe48480cdcda4dff7606a5ba1cbc5580 [file] [log] [blame]
<!DOCTYPE html>
<!--
Copyright (c) 2015 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->
<link rel="import" href="/core/trace_model/attribute.html">
<link rel="import" href="/core/trace_model/container_memory_dump.html">
<link rel="import" href="/core/trace_model/memory_allocator_dump.html">
<script>
'use strict';
tv.b.unittest.testSuite(function() {
var ContainerMemoryDump = tv.c.trace_model.ContainerMemoryDump;
var MemoryAllocatorDump = tv.c.trace_model.MemoryAllocatorDump;
var MemoryAllocatorDumpLink = tv.c.trace_model.MemoryAllocatorDumpLink;
var ScalarAttribute = tv.c.trace_model.ScalarAttribute;
function setUpParentChildRelationship(parent, child) {
child.parent = parent;
parent.children.push(child);
}
test('memoryAllocatorDumps_aggregateAttributes', function() {
var md = new ContainerMemoryDump(42);
var oilpanDump = new MemoryAllocatorDump(md, 'oilpan');
oilpanDump.addAttribute('objects_count', new ScalarAttribute('objects', 7));
var oilpanBucket1Dump = new MemoryAllocatorDump(
md, 'oilpan/bucket1', oilpanDump);
oilpanBucket1Dump.addAttribute('outer_size',
new ScalarAttribute('bytes', 512));
oilpanBucket1Dump.addAttribute('objects_count',
new ScalarAttribute('objects', 3));
oilpanBucket1Dump.addAttribute('inner_size',
new ScalarAttribute('bytes', 256));
setUpParentChildRelationship(oilpanDump, oilpanBucket1Dump);
var oilpanBucket2Dump = new MemoryAllocatorDump(
md, 'oilpan/bucket2', oilpanDump);
setUpParentChildRelationship(oilpanDump, oilpanBucket2Dump);
var oilpanBucket2StringsDump = new MemoryAllocatorDump(
md, 'oilpan/bucket2/strings', oilpanBucket2Dump);
oilpanBucket2StringsDump.addAttribute('outer_size',
new ScalarAttribute('bytes', 512));
oilpanBucket2StringsDump.addAttribute('objects_count',
new ScalarAttribute('objects', 4));
oilpanBucket2StringsDump.addAttribute('inner_size',
new ScalarAttribute('bytes', 512));
setUpParentChildRelationship(oilpanBucket2Dump, oilpanBucket2StringsDump);
oilpanDump.aggregateAttributes();
// oilpan has *some* attributes aggregated.
assert.equal(oilpanDump.attributes['objects_count'].value, 7);
assert.equal(oilpanDump.attributes['inner_size'].value, 768);
assert.equal(oilpanDump.attributes['outer_size'].value, 1024);
// oilpan/bucket2 has *all* attributes aggregated.
assert.equal(oilpanBucket2Dump.attributes['objects_count'].value,
4);
assert.equal(oilpanBucket2Dump.attributes['inner_size'].value, 512);
assert.equal(oilpanBucket2Dump.attributes['outer_size'].value, 512);
// oilpan/bucket2/strings has *no* attributes aggregated.
assert.equal(oilpanBucket2StringsDump.attributes[
'objects_count'].value, 4);
assert.equal(oilpanBucket2StringsDump.attributes['inner_size'].value, 512);
assert.equal(oilpanBucket2StringsDump.attributes['outer_size'].value, 512);
});
test('memoryAllocatorDumpLink_instantiate', function() {
var d1 = new MemoryAllocatorDump('v8/isolate1');
var d2 = new MemoryAllocatorDump('oilpan/document1');
var link = new MemoryAllocatorDumpLink(d1, d2, 3);
assert.strictEqual(link.source, d1);
assert.strictEqual(link.target, d2);
assert.strictEqual(link.importance, 3);
});
});
</script>