Ejemplo n.º 1
0
        public static void CompareMemorySnapshots(MemorySnapshot oldSnapshot, MemorySnapshot newSnapshot, MemorySnapshot difSnapshot, CompareMode compareMode)
        {
            difSnapshot.Reset();

            CompareMemorySnapshots(oldSnapshot, newSnapshot, difSnapshot, CompareResult.Removed);
            CompareMemorySnapshots(newSnapshot, oldSnapshot, difSnapshot, CompareResult.New);

            difSnapshot.memoryTypesLookup.Sort(compareMode);
        }
Ejemplo n.º 2
0
        public static void CompareMemorySnapshots(MemorySnapshot s, MemorySnapshot d, MemorySnapshot difSnapshot, CompareResult compareResult)
        {
            var sMemoryTypesLookup = s.memoryTypesLookup;
            var dMemoryTypesLookup = d.memoryTypesLookup;

            var sList = sMemoryTypesLookup.list;

            // Compare s with d
            for (int i = 0; i < sList.Count; i++)
            {
                ItemHolder <string, MemoryInstanceType> item = sList.items[i];
                MemoryInstanceType sMemoryInstanceType       = item.value;
                MemoryInstanceType dMemoryInstanceType;
                MemoryInstanceType difMemoryInstanceType = null;
                string             typeName = item.key;

                bool allSame = true;
                if (dMemoryTypesLookup.lookup.TryGetValue(typeName, out dMemoryInstanceType))
                {
                    // d Snapshot contains instance of item Type (could be all the same)
                    FastSortedHashSet <int, MemoryObject> sInstances = sMemoryInstanceType.instances;
                    HashSet <int> dInstancesLookup = dMemoryInstanceType.instances.lookup;

                    FastList <MemoryObject> sInstanceList = sInstances.list;

                    for (int j = 0; j < sInstanceList.Count; j++)
                    {
                        MemoryObject sMemoryObject = sInstanceList.items[j];

                        if (dInstancesLookup.Contains(sMemoryObject.instanceId))
                        {
                            continue;
                        }

                        // Add when doesn't contain
                        if (allSame)
                        {
                            allSame = false;
                            if (!difSnapshot.memoryTypesLookup.lookup.TryGetValue(typeName, out difMemoryInstanceType))
                            {
                                difMemoryInstanceType = new MemoryInstanceType(sMemoryInstanceType.type);
                                difSnapshot.memoryTypesLookup.Add(typeName, difMemoryInstanceType);
                                // DrawInfo info = GetObjectDrawInfo(difSnapshot.memoryLookup, typeName, true);
                            }
                        }

                        difMemoryInstanceType.instances.Add(sMemoryObject.instanceId, new MemoryObject(sMemoryObject, compareResult));
                    }
                }
                else
                {
                    // Add all instances
                    difMemoryInstanceType = new MemoryInstanceType(sMemoryInstanceType.type);
                    difSnapshot.memoryTypesLookup.Add(typeName, difMemoryInstanceType);
                    // DrawInfo info = GetObjectDrawInfo(difSnapshot.memoryLookup, typeName, true);
                    var sInstanceList = sMemoryInstanceType.instances.list;

                    for (int j = 0; j < sInstanceList.Count; j++)
                    {
                        difMemoryInstanceType.instances.Add(sInstanceList.items[j].instanceId, new MemoryObject(sInstanceList.items[j], compareResult));
                    }
                }
            }
        }