コード例 #1
0
ファイル: Histogram.cs プロジェクト: ScriptBox21/MS-perfview
        /// <summary>
        /// Initialize a new ScenarioHistogramController.
        /// </summary>
        /// <param name="tree">The CallTree to manage.</param>
        /// <param name="scenarios">An ordered array of scenario IDs to display.</param>
        /// <param name="totalScenarios">The total number of possible scenarios that can be supplied by the underlying StackSource.
        /// This number might be larger than the highest number in <paramref name="scenarios"/>.</param>
        /// <param name="scenarioNames">The names of the scenarios (for UI use).</param>
        public ScenarioHistogramController(CallTree tree, int[] scenarios, int totalScenarios, string[] scenarioNames = null)
            : base(tree)
        {
            Debug.Assert(totalScenarios > 0);

            BucketCount    = totalScenarios;
            CharacterCount = Math.Min(scenarios.Length, CharacterCount);

            m_scenariosFromCharacter = new List <int> [CharacterCount];
            m_characterFromScenario  = new HistogramCharacterIndex[BucketCount];

            for (int i = 0; i < CharacterCount; i++)
            {
                m_scenariosFromCharacter[i] = new List <int>();
            }

            for (int i = 0; i < BucketCount; i++)
            {
                m_characterFromScenario[i] = HistogramCharacterIndex.Invalid;
            }

            for (int i = 0; i < scenarios.Length; i++)
            {
                var scenario = scenarios[i];
                var bucket   = (i * CharacterCount) / scenarios.Length;

                m_characterFromScenario[scenario] = (HistogramCharacterIndex)bucket;
                m_scenariosFromCharacter[bucket].Add(scenario);
            }

            m_scenarioNames = scenarioNames;
        }
コード例 #2
0
ファイル: Histogram.cs プロジェクト: ScriptBox21/MS-perfview
        /// <summary>
        /// Implements HistogramController interface
        /// </summary>
        public override string GetInfoForCharacterRange(HistogramCharacterIndex start, HistogramCharacterIndex end, Histogram histogram)
        {
            var rangeStart = GetStartTimeForBucket(start);
            var rangeEnd   = GetStartTimeForBucket(end);

            var cumStats = "";

            if (start != HistogramCharacterIndex.Invalid && end != HistogramCharacterIndex.Invalid && start < end)
            {
                float cumStart = 0;
                for (int i = 0; i < (int)start; i++)
                {
                    cumStart += histogram[i];
                }

                float cum    = cumStart;
                float cumMax = cumStart;
                HistogramCharacterIndex cumMaxIdx = start;

                for (HistogramCharacterIndex i = start; i < end; i++)
                {
                    var val = histogram[(int)i];
                    cum += val;
                    if (cum > cumMax)
                    {
                        cumMax    = cum;
                        cumMaxIdx = i + 1;
                    }
                }
                cumStats = string.Format(" CumStart:{0,9:n3}M Cum:{1,9:n3}M  CumMax:{2,9:n3}M at {3,11:n3}ms",
                                         cumStart / 1000000, cum / 1000000, cumMax / 1000000, GetStartTimeForBucket(cumMaxIdx));
            }

            return(string.Format("TimeRange = {0,11:n3} - {1,11:n3} Duration {2,9:n3}ms{3}", rangeStart, rangeEnd, rangeEnd - rangeStart, cumStats));
        }
コード例 #3
0
ファイル: Histogram.cs プロジェクト: ScriptBox21/MS-perfview
        /// <summary>
        /// Get a list of scenarios contained in a given bucket range.
        /// </summary>
        /// <param name="start">The start of the bucket range (inclusive).</param>
        /// <param name="end">The end of the bucket range (exclusive).</param>
        /// <returns>The scenarios contained in that range of buckets.</returns>
        public int[] GetScenariosForCharacterRange(HistogramCharacterIndex start, HistogramCharacterIndex end)
        {
            var rv = new List <int>();

            for (var bucket = start; bucket < end; bucket++)
            {
                rv.AddRange(m_scenariosFromCharacter[(int)bucket]);
            }

            return(rv.ToArray());
        }
コード例 #4
0
        /// <summary>
        /// Get the human-readable names for all scenarios contained in a range of histogram characters.
        /// </summary>
        /// <param name="start">The (inclusive) start index of the range.</param>
        /// <param name="end">The (exclusive) end index of the range.</param>
        /// <param name="histogram">The histogram.</param>
        /// <returns>A comma-separated list of scenario names contained in that range.</returns>
        public override string GetInfoForCharacterRange(HistogramCharacterIndex start, HistogramCharacterIndex end, Histogram histogram)
        {
            var sb = new StringBuilder();

            for (var bucket = start; bucket < end; bucket++)
            {
                if (bucket == start)
                {
                    sb.Append("Scenarios: ");
                }
                foreach (int scenario in m_scenariosFromCharacter[(int)bucket])
                {
                    sb.AppendFormat("{0}, ", GetNameForScenario(scenario));
                }
            }
            if (2 <= sb.Length)
            {
                sb.Remove(sb.Length - 2, 2);
            }
            return(sb.ToString());
        }
コード例 #5
0
ファイル: Histogram.cs プロジェクト: ScriptBox21/MS-perfview
        /// <summary>
        /// Gets the start time for the histogram bucket represented by a character.
        /// </summary>
        /// <param name="bucket">The index of the character to look up.</param>
        /// <returns>The start time of the bucket represented by the character.</returns>
        public double GetStartTimeForBucket(HistogramCharacterIndex bucket)
        {
            Debug.Assert(bucket != HistogramCharacterIndex.Invalid);

            return((BucketDuration * (int)bucket) + Start);
        }
コード例 #6
0
ファイル: Histogram.cs プロジェクト: ScriptBox21/MS-perfview
 /// <summary>
 /// Get a list of scenarios contained in a given bucket.
 /// </summary>
 /// <param name="bucket">The bucket to look up.</param>
 /// <returns>The scenarios contained in that bucket.</returns>
 public int[] GetScenariosForCharacterIndex(HistogramCharacterIndex bucket)
 {
     return(m_scenariosFromCharacter[(int)bucket].ToArray());
 }
コード例 #7
0
ファイル: Histogram.cs プロジェクト: ScriptBox21/MS-perfview
 /// <summary>
 /// Gets human-readable information about a range of histogram characters.
 /// </summary>
 /// <param name="start">The start character index (inclusive).</param>
 /// <param name="end">The end character index (exclusive).</param>
 /// <param name="histogram">The histogram.</param>
 /// <returns>A string containing information about the contents of that character range.</returns>
 public abstract string GetInfoForCharacterRange(HistogramCharacterIndex start, HistogramCharacterIndex end, Histogram histogram);