示例#1
0
        private void AppendEvent(ProfilingResult profilingResult, int elapsedFrames, long tickFrequency, bool displayMarkCount)
        {
            var profilingEvent = profilingResult.Event.Value;

            Profiler.AppendTime(profilersStringBuilder, profilingResult.AccumulatedTime / elapsedFrames, tickFrequency);
            profilersStringBuilder.Append(" | ");
            Profiler.AppendTime(profilersStringBuilder, profilingResult.AccumulatedTime / profilingResult.Count, tickFrequency);
            profilersStringBuilder.Append(" | ");
            Profiler.AppendTime(profilersStringBuilder, profilingResult.MinTime, tickFrequency);
            profilersStringBuilder.Append(" | ");
            Profiler.AppendTime(profilersStringBuilder, profilingResult.MaxTime, tickFrequency);
            profilersStringBuilder.Append(" | ");
            profilersStringBuilder.AppendFormat("{0:00.00}", profilingResult.Count / (double)elapsedFrames);
            profilersStringBuilder.Append(" | ");

            if (displayMarkCount)
            {
                profilersStringBuilder.AppendFormat("{0:00.00}", profilingResult.MarkCount / (double)elapsedFrames);
                profilersStringBuilder.Append(" | ");
            }

            profilersStringBuilder.Append(profilingEvent.Key);
            // ReSharper disable once ReplaceWithStringIsNullOrEmpty
            // This was creating memory allocation (GetEnumerable())
            if (profilingEvent.Text != null && profilingEvent.Text != string.Empty)
            {
                profilersStringBuilder.Append(" / ");
                profilersStringBuilder.AppendFormat(profilingEvent.Text, GetValue(profilingResult.Custom0), GetValue(profilingResult.Custom1), GetValue(profilingResult.Custom2), GetValue(profilingResult.Custom3));
            }

            profilersStringBuilder.Append("\n");
        }
            public void AssertBetterThan(ProfilingResult that)
            {
                var durationScore = (this.Duration - that.Duration).Duration() < TimeSpan.FromMilliseconds(this.Duration.TotalMilliseconds / 200)
                    ? 0
                    : this.Duration.CompareTo(that.Duration);

                var enumerateScore = this.EnumerateCount.CompareTo(that.EnumerateCount);
                // allow equals to vary by 1 because of the sequence equal optimization
                var equalsScore = Math.Abs(this.EqualsCount - that.EqualsCount) > 1 ? this.EqualsCount.CompareTo(that.EqualsCount) : 0;
                var hashScore   = this.HashCount.CompareTo(that.HashCount);

                var scores = new[] { durationScore, enumerateScore, equalsScore, hashScore };

                Assert.True(scores.All(i => i <= 0), "Scores: " + string.Join(", ", scores));
                Assert.True(scores.Any(i => i < 0), "Scores: " + string.Join(", ", scores));
            }
示例#3
0
        private void AppendEvent(ProfilingResult profilingResult, ProfilingEvent e, double elapsedTime)
        {
            profilersStringBuilder.AppendFormat("{0,-7:P1}", profilingResult.AccumulatedTime / elapsedTime);
            profilersStringBuilder.Append(" |  ");

            if ((e.Key.Flags & ProfilingKeyFlags.GpuProfiling) == ProfilingKeyFlags.GpuProfiling)
            {
                double gpuTimestampFrequency = GraphicsDevice.TimestampFrequency / 1000.0;

                double minTimeMs = profilingResult.MinTime / gpuTimestampFrequency;
                double accTimeMs = (profilingResult.Count != 0 ? profilingResult.AccumulatedTime / (double)profilingResult.Count : 0.0) / gpuTimestampFrequency;
                double maxTimeMs = profilingResult.MaxTime / gpuTimestampFrequency;

                profilersStringBuilder.AppendFormat("{0:000.000}ms", minTimeMs);
                profilersStringBuilder.Append(" |  ");
                profilersStringBuilder.AppendFormat("{0:000.000}ms", accTimeMs);
                profilersStringBuilder.Append(" |  ");
                profilersStringBuilder.AppendFormat("{0:000.000}ms", maxTimeMs);
            }
            else
            {
                Profiler.AppendTime(profilersStringBuilder, profilingResult.MinTime);
                profilersStringBuilder.Append(" |  ");
                Profiler.AppendTime(profilersStringBuilder, profilingResult.Count != 0 ? profilingResult.AccumulatedTime / profilingResult.Count : 0);
                profilersStringBuilder.Append(" |  ");
                Profiler.AppendTime(profilersStringBuilder, profilingResult.MaxTime);
            }

            profilersStringBuilder.Append(" | ");
            profilersStringBuilder.Append(e.Key);
            profilersStringBuilder.Append(" ");
            // ReSharper disable once ReplaceWithStringIsNullOrEmpty
            // This was creating memory allocation (GetEnumerable())
            if (e.Text != null && e.Text != "")
            {
                profilersStringBuilder.AppendFormat(e.Text, GetValue(profilingResult.Custom0), GetValue(profilingResult.Custom1), GetValue(profilingResult.Custom2), GetValue(profilingResult.Custom3));
            }

            profilersStringBuilder.Append("\n");
        }
示例#4
0
        private void AppendEvent(ProfilingResult profilingResult, ProfilingEvent e, double elapsedTime)
        {
            profilersStringBuilder.AppendFormat("{0,-7:P1}", profilingResult.AccumulatedTime / elapsedTime);
            profilersStringBuilder.Append(" |  ");
            Profiler.AppendTime(profilersStringBuilder, profilingResult.MinTime);
            profilersStringBuilder.Append(" |  ");
            Profiler.AppendTime(profilersStringBuilder, profilingResult.Count != 0 ? profilingResult.AccumulatedTime / profilingResult.Count : 0);
            profilersStringBuilder.Append(" |  ");
            Profiler.AppendTime(profilersStringBuilder, profilingResult.MaxTime);

            profilersStringBuilder.Append(" | ");
            profilersStringBuilder.Append(e.Key);
            profilersStringBuilder.Append(" ");
            // ReSharper disable once ReplaceWithStringIsNullOrEmpty
            // This was creating memory allocation (GetEnumerable())
            if (e.Text != null && e.Text != "")
            {
                profilersStringBuilder.AppendFormat(e.Text, GetValue(profilingResult.Custom0), GetValue(profilingResult.Custom1), GetValue(profilingResult.Custom2), GetValue(profilingResult.Custom3));
            }

            profilersStringBuilder.Append("\n");
        }