Пример #1
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");
        }
Пример #2
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");
        }