test_HeapAnalyses_takeCensusDiff_01.js (1743B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 "use strict"; 4 5 // Test that the HeapAnalyses{Client,Worker} can take diffs between censuses. 6 7 const BREAKDOWN = { 8 by: "objectClass", 9 then: { by: "count", count: true, bytes: false }, 10 other: { by: "count", count: true, bytes: false }, 11 }; 12 13 add_task(async function () { 14 const client = new HeapAnalysesClient(); 15 16 const markers = [allocationMarker()]; 17 18 const firstSnapshotFilePath = saveNewHeapSnapshot(); 19 20 // Allocate and hold an additional AllocationMarker object so we can see it in 21 // the next heap snapshot. 22 markers.push(allocationMarker()); 23 24 const secondSnapshotFilePath = saveNewHeapSnapshot(); 25 26 await client.readHeapSnapshot(firstSnapshotFilePath); 27 await client.readHeapSnapshot(secondSnapshotFilePath); 28 ok(true, "Should have read both heap snapshot files"); 29 30 const { delta } = await client.takeCensusDiff( 31 firstSnapshotFilePath, 32 secondSnapshotFilePath, 33 { breakdown: BREAKDOWN } 34 ); 35 36 equal( 37 delta.AllocationMarker.count, 38 1, 39 "There exists one new AllocationMarker in the second heap snapshot" 40 ); 41 42 const { delta: deltaTreeNode } = await client.takeCensusDiff( 43 firstSnapshotFilePath, 44 secondSnapshotFilePath, 45 { breakdown: BREAKDOWN }, 46 { asTreeNode: true } 47 ); 48 49 // Have to manually set these because symbol properties aren't structured 50 // cloned. 51 delta[CensusUtils.basisTotalBytes] = deltaTreeNode.totalBytes; 52 delta[CensusUtils.basisTotalCount] = deltaTreeNode.totalCount; 53 54 compareCensusViewData( 55 BREAKDOWN, 56 delta, 57 deltaTreeNode, 58 "Returning delta-census as a tree node represents same data as the report" 59 ); 60 61 client.destroy(); 62 });