Exemple #1
0
        private void RefreshSnapshots()
        {
            SnapshotTimeline.Items = Instance.Snapshots;
            SnapshotTimeline.Invalidate();

            DiffSelection.Enabled = SnapshotTimeline.HasSelection &&
                                    (SnapshotTimeline.Selection.First != SnapshotTimeline.Selection.Second);
            ViewSelection.Enabled = SnapshotTimeline.HasSelection &&
                                    (SnapshotTimeline.Selection.First == SnapshotTimeline.Selection.Second);
        }
Exemple #2
0
        protected IEnumerator <object> UpdateStats()
        {
            yield return(Instance.UpdateFilteredTracebacks());

            var fDataSeries = Instance.GenerateTopFunctions();

            yield return(fDataSeries);

            SnapshotTimeline.DataSeries.Clear();
            foreach (var kvp in fDataSeries.Result)
            {
                SnapshotTimeline.DataSeries.Add(kvp.Key, kvp.Value);
            }

            SnapshotTimeline.Invalidate();
        }
Exemple #3
0
        protected IEnumerator <object> FilterHeapData(HeapRecording instance, string filter)
        {
            var result = new Dictionary <HeapSnapshotInfo, FilteredHeapSnapshotInfo>();

            filter = EscapeFilter(filter);
            var regex         = new Regex(filter);
            var functionNames = (from functionName in KnownFunctionNames
                                 where regex.IsMatch(functionName)
                                 select functionName).Distinct();

            using (var activity = Activities.AddItem("Filtering heap")) {
                var fFrameIDs = instance.Database.SymbolsByFunction.Find(functionNames);
                using (fFrameIDs)
                    yield return(fFrameIDs);

                var frameIDs = new HashSet <UInt32>(
                    from key in fFrameIDs.Result select BitConverter.ToUInt32(key.Data.Array, key.Data.Offset)
                    );

                for (int i = 0, c = instance.Snapshots.Count; i < c; i++)
                {
                    activity.Maximum  = c;
                    activity.Progress = i;

                    var info = instance.Snapshots[i];

                    var fSnapshot = instance.GetSnapshot(info);
                    using (fSnapshot)
                        yield return(fSnapshot);

                    var snapshot = fSnapshot.Result;
                    Func <HeapSnapshot.Traceback, bool> tracebackMatches = (traceback) => {
                        var _f = traceback.Frames.Array;
                        for (int _i = 0, _c = traceback.Frames.Count, _o = traceback.Frames.Offset; _i < _c; _i++)
                        {
                            if (frameIDs.Contains(_f[_i + _o]))
                            {
                                return(true);
                            }
                        }

                        return(false);
                    };

                    var fMatchingTracebacks = Future.RunInThread(() => new HashSet <UInt32>(
                                                                     from traceback in snapshot.Tracebacks.AsParallel() where tracebackMatches(traceback) select traceback.ID
                                                                     ));
                    yield return(fMatchingTracebacks);

                    var matchingTracebacks = fMatchingTracebacks.Result;

                    var fInfo = Future.RunInThread(() => new FilteredHeapSnapshotInfo(
                                                       (from heap in snapshot.Heaps.AsParallel() select(from alloc in heap.Allocations.AsParallel() where matchingTracebacks.Contains(alloc.TracebackID) select(long) alloc.Size).Sum()).Sum(),
                                                       (from heap in snapshot.Heaps.AsParallel() select(from alloc in heap.Allocations.AsParallel() where matchingTracebacks.Contains(alloc.TracebackID) select(long) alloc.Overhead).Sum()).Sum(),
                                                       (from heap in snapshot.Heaps.AsParallel() select(from alloc in heap.Allocations.AsParallel() where matchingTracebacks.Contains(alloc.TracebackID) select(long)(alloc.Size + alloc.Overhead)).Sum()).Sum(),
                                                       (from heap in snapshot.Heaps.AsParallel() select(from alloc in heap.Allocations.AsParallel() where matchingTracebacks.Contains(alloc.TracebackID) select alloc).Count()).Sum()
                                                       ));

                    yield return(fInfo);

                    result[info] = fInfo.Result;

                    info.ReleaseStrongReference();
                }
            }

            CurrentFilterData   = result;
            CurrentFilter       = filter;
            PendingFilter       = null;
            PendingFilterFuture = null;

            SnapshotTimeline.Invalidate();
        }