Beispiel #1
0
 void DoneReloadingTracebacks()
 {
     DeltaList.Invalidate();
     DeltaHistogram.Invalidate();
     GraphHistogram.Invalidate();
     SetBusy(false);
     Enabled = true;
 }
Beispiel #2
0
        public IEnumerator <object> RefreshDeltas()
        {
            if (Updating)
            {
                yield break;
            }

            SetBusy(true);

            Future <int> fTotalBytes  = new Future <int>(),
                         fTotalAllocs = new Future <int>(),
                         fMax         = new Future <int>();
            var newListItems          = new List <DeltaInfo>();
            var moduleList            = ModuleList;
            var deltas         = Deltas;
            var functionFilter = FunctionFilter;

            yield return(Future.RunInThread(() => {
                int max = -int.MaxValue;
                int totalBytes = 0, totalAllocs = 0;

                foreach (var delta in deltas)
                {
                    if (functionFilter != null)
                    {
                        bool matched = false;

                        foreach (var functionName in delta.Traceback.Functions)
                        {
                            if (functionFilter.IsMatch(functionName))
                            {
                                matched = true;
                                break;
                            }
                        }

                        if (!matched)
                        {
                            continue;
                        }
                    }

                    bool filteredOut = (delta.Traceback.Modules.Count > 0);
                    foreach (var module in delta.Traceback.Modules)
                    {
                        filteredOut &= !moduleList.SelectedItems.Contains(module);

                        if (!filteredOut)
                        {
                            break;
                        }
                    }

                    if (!filteredOut)
                    {
                        newListItems.Add(delta);
                        totalBytes += delta.BytesDelta * (delta.Added ? 1 : -1);
                        totalAllocs += delta.CountDelta.GetValueOrDefault(0) * (delta.Added ? 1 : -1);
                        max = Math.Max(max, delta.BytesDelta);
                    }
                }

                max = Math.Max(max, Math.Abs(totalBytes));
                fTotalBytes.Complete(totalBytes);
                fTotalAllocs.Complete(totalAllocs);
                fMax.Complete(max);
            }));

            StatusLabel.Text      = String.Format("Showing {0} out of {1} item(s)", newListItems.Count, deltas.Count);
            AllocationTotals.Text = String.Format("Delta bytes: {0} Delta allocations: {1}", FileSize.Format(fTotalBytes.Result), fTotalAllocs.Result);

            DeltaHistogram.Items = DeltaList.Items = newListItems;
            if (newListItems.Count > 0)
            {
                DeltaHistogram.Maximum = fMax.Result;
            }
            else
            {
                DeltaHistogram.Maximum = 1024;
            }
            DeltaHistogram.TotalDelta = fTotalBytes.Result;

            DeltaList.Invalidate();
            DeltaHistogram.Invalidate();

            SetBusy(false);
        }