Exemplo n.º 1
0
        protected void DiffLoaded(HeapDiff diff, string filename)
        {
            Modules = diff.Modules;
            FunctionNames = diff.FunctionNames;
            Deltas = diff.Deltas;
            FilteredDeltas = null;
            StackGraph = null;

            TracebackFilter.AutoCompleteItems = FunctionNames;

            Text = "Diff Viewer - " + filename;
            Filename = filename;

            RefreshModules();

            if (PendingRefresh != null)
                PendingRefresh.Dispose();
            PendingRefresh = Start(RefreshDeltas());

            MainMenuStrip.Enabled = true;
            LoadingPanel.Visible = false;
            MainSplit.Visible = true;
            Timeline.Enabled = true;
            UseWaitCursor = false;
        }
Exemplo n.º 2
0
        protected IEnumerator<object> GenerateNewGraph(List<DeltaInfo> newListItems, GraphKeyType keyType)
        {
            var newGraph = new StackGraph(keyType);
            yield return newGraph.Build(Instance, newListItems);

            StackGraph = newGraph;
            GraphHistogram.Items = StackGraph.Functions.OrderedItems.ToArray();
            GraphTreemap.Items = StackGraph.OrderedItems.ToArray();

            GraphHistogram.Invalidate();
            GraphTreemap.Refresh();
        }
Exemplo n.º 3
0
        protected IEnumerator<object> _GenerateTopFunctions()
        {
            var topNodes = new List<StackGraphNode[]>();
            const int resultCount = 10;

            using (var activity = Activities.AddItem("Finding top functions")) {
                for (int i = 0, c = Snapshots.Count; i < c; i++) {
                    activity.Maximum = c + 1;

                    var info = Snapshots[i];

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

                    var snapshot = fSnapshot.Result;

                    var tracebackIds = (from heap in snapshot.Heaps
                        from allocation in heap.Allocations
                        select allocation.TracebackID).Distinct().ToArray();

                    var fTracebacks = Database.FilteredTracebacks.CascadingSelect(
                        new [] { Database.Tracebacks }, tracebackIds
                    );

                    yield return fTracebacks;

                    var frameIds = (from traceback in fTracebacks.Result
                                    from frame in traceback
                                    select frame).Distinct().ToArray();

                    var fSymbols = Database.SymbolCache.Select(frameIds);

                    yield return fSymbols;

                    var tracebacks = SequenceUtils.ToDictionary(
                        tracebackIds, fTracebacks.Result
                    );

                    var symbols = SequenceUtils.ToDictionary(
                        frameIds, fSymbols.Result
                    );

                    var graph = new StackGraph(GraphKeyType.Function);

                    yield return graph.Build(snapshot, tracebacks, symbols);

                    topNodes.Add(graph.OrderedItems.Take(resultCount).ToArray());

                    info.ReleaseStrongReference();

                    activity.Progress = i;
                }

                var fTopFunctions = Future.RunInThread(() => {
                    var grouped =
                        from ti in topNodes
                        from node in ti
                        group node by node.Key
                            into nodeGroup
                            select new {
                                key = nodeGroup.Key,
                                maxBytes = nodeGroup.Max((sgn) => sgn.BytesRequested)
                            };

                    var sorted = (from item in grouped
                           orderby item.maxBytes descending
                           select item);

                    var result = new Dictionary<string, int[]>();

                    foreach (var item in sorted) {
                        var resultArray = new int[Snapshots.Count];

                        for (int j = 0; j < resultArray.Length; j++)
                            resultArray[j] = (from sgn in topNodes[j]
                                              where sgn.Key.Equals(item.key)
                                              select sgn.BytesRequested).FirstOrDefault();

                        result[item.key.FunctionName] = resultArray;
                    }

                    return result;
                });

                yield return fTopFunctions;

                yield return new Result(fTopFunctions.Result);
            }
        }