From a6b1cc1d5a406e819e372f11b03151bf6334cce0 Mon Sep 17 00:00:00 2001 From: ikpil Date: Sat, 1 Jul 2023 13:12:29 +0900 Subject: [PATCH] remove Tuple --- src/DotRecast.Core/RcTelemetryTick.cs | 1 + src/DotRecast.Detour.Crowd/DtCrowdTelemetry.cs | 9 ++++++--- .../Tools/CrowdProfilingTool.cs | 12 ++++-------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/DotRecast.Core/RcTelemetryTick.cs b/src/DotRecast.Core/RcTelemetryTick.cs index a2c84df..535f086 100644 --- a/src/DotRecast.Core/RcTelemetryTick.cs +++ b/src/DotRecast.Core/RcTelemetryTick.cs @@ -7,6 +7,7 @@ namespace DotRecast.Core public readonly string Key; public readonly long Ticks; public long Millis => Ticks / TimeSpan.TicksPerMillisecond; + public long Micros => Ticks / 10; // TimeSpan.TicksPerMicrosecond; public RcTelemetryTick(string key, long ticks) { diff --git a/src/DotRecast.Detour.Crowd/DtCrowdTelemetry.cs b/src/DotRecast.Detour.Crowd/DtCrowdTelemetry.cs index bed09e7..442b20f 100644 --- a/src/DotRecast.Detour.Crowd/DtCrowdTelemetry.cs +++ b/src/DotRecast.Detour.Crowd/DtCrowdTelemetry.cs @@ -29,7 +29,7 @@ namespace DotRecast.Detour.Crowd public const int TIMING_SAMPLES = 10; private float _maxTimeToEnqueueRequest; private float _maxTimeToFindPath; - + private readonly Dictionary _executionTimings = new Dictionary(); private readonly Dictionary> _executionTimingSamples = new Dictionary>(); @@ -43,9 +43,12 @@ namespace DotRecast.Detour.Crowd return _maxTimeToFindPath; } - public Dictionary ToExecutionTimings() + public List ToExecutionTimings() { - return _executionTimings; + return _executionTimings + .Select(e => new RcTelemetryTick(e.Key, e.Value)) + .OrderByDescending(x => x.Ticks) + .ToList(); } public void Start() diff --git a/src/DotRecast.Recast.Demo/Tools/CrowdProfilingTool.cs b/src/DotRecast.Recast.Demo/Tools/CrowdProfilingTool.cs index 7b41e52..3bb7fd2 100644 --- a/src/DotRecast.Recast.Demo/Tools/CrowdProfilingTool.cs +++ b/src/DotRecast.Recast.Demo/Tools/CrowdProfilingTool.cs @@ -22,7 +22,6 @@ using System.Linq; using DotRecast.Core; using DotRecast.Detour; using DotRecast.Detour.Crowd; - using DotRecast.Recast.DemoTool.Builder; using DotRecast.Recast.Demo.Draw; using DotRecast.Recast.DemoTool; @@ -131,15 +130,12 @@ public class CrowdProfilingTool { ImGui.Text($"Max time to enqueue request: {crowd.Telemetry().MaxTimeToEnqueueRequest()} s"); ImGui.Text($"Max time to find path: {crowd.Telemetry().MaxTimeToFindPath()} s"); - List> timings = crowd.Telemetry() - .ToExecutionTimings() - .Select(e => Tuple.Create(e.Key, e.Value)) - .OrderBy(x => x.Item2) - .ToList(); + var timings = crowd.Telemetry() + .ToExecutionTimings(); - foreach (Tuple e in timings) + foreach (var rtt in timings) { - ImGui.Text($"{e.Item1}: {e.Item2 / TimeSpan.TicksPerMicrosecond} us"); + ImGui.Text($"{rtt.Key}: {rtt.Micros} us"); } ImGui.Text($"Update Time: {crowdUpdateTime} ms");