Exemple #1
0
        public static ProfileReport GenerateFromSamples(long frequency, List <ProfileSample> samples)
        {
            ProfileReport report = new ProfileReport();

            report.m_frequency = frequency;

            int size = samples.Count;

            for (int i = 0; i < size; ++i)
            {
                if (samples[i].Enter)
                {
                    FunctionCall f = new FunctionCall(samples[i].Name, samples[i].Time, samples[i].Color);

                    if (!RecGenerate(report, samples, ref i, f))
                    {
                        // the function never ended, so make the end time equal to the last end time
                        if (f.Children.Count > 0)
                        {
                            f.EndTime = f.Children[f.Children.Count - 1].EndTime;
                        }
                        else
                        {
                            f.EndTime = f.StartTime;
                        }
                    }

                    report.m_allFunctionCalls.Add(f);
                    report.m_topHierarchy.Add(f);
                }
            }
            return(report);
        }
Exemple #2
0
        private static bool RecGenerate(ProfileReport report, List <ProfileSample> samples, ref int i, FunctionCall f)
        {
            int size = samples.Count;

            ++i;

            for (; i < size; ++i)
            {
                if (samples[i].Enter)
                {
                    FunctionCall fchild = new FunctionCall(samples[i].Name, samples[i].Time, samples[i].Color);

                    RecGenerate(report, samples, ref i, fchild);

                    f.AddChild(fchild);

                    report.m_allFunctionCalls.Add(fchild);
                }
                else
                {
                    f.EndTime = samples[i].Time;
                    return(true);
                }
            }

            return(false);
        }
Exemple #3
0
        public void HandleProfileMessage(DebugMessage msg)
        {
            ProfileReportMessage m = msg as ProfileReportMessage;

            if (m != null)
            {
                ProfileReport report = ProfileReport.GenerateFromSamples(m.Frequency, m.Samples);
                if (report != null)
                {
                    m_reports.Add(report);
                    UpdateListView();
                }
            }
        }