From f9782da010ee31c38498478a47de5ece93b04fbe Mon Sep 17 00:00:00 2001 From: ikpil Date: Fri, 14 Apr 2023 22:41:29 +0900 Subject: [PATCH] rename FrequencyWatch --- .../{TickWatch.cs => FrequencyWatch.cs} | 2 +- src/DotRecast.Detour.Crowd/CrowdTelemetry.cs | 4 ++-- src/DotRecast.Recast.Demo/RecastDemo.cs | 6 +++--- .../Tools/CrowdProfilingTool.cs | 4 ++-- src/DotRecast.Recast.Demo/Tools/CrowdTool.cs | 4 ++-- src/DotRecast.Recast.Demo/Tools/DynamicUpdateTool.cs | 12 ++++++------ src/DotRecast.Recast/Telemetry.cs | 4 ++-- test/DotRecast.Detour.Test/RandomPointTest.cs | 6 +++--- .../DotRecast.Detour.TileCache.Test/TileCacheTest.cs | 6 +++--- test/DotRecast.Recast.Test/RecastSoloMeshTest.cs | 6 +++--- test/DotRecast.Recast.Test/RecastTileMeshTest.cs | 6 +++--- 11 files changed, 30 insertions(+), 30 deletions(-) rename src/DotRecast.Core/{TickWatch.cs => FrequencyWatch.cs} (87%) diff --git a/src/DotRecast.Core/TickWatch.cs b/src/DotRecast.Core/FrequencyWatch.cs similarity index 87% rename from src/DotRecast.Core/TickWatch.cs rename to src/DotRecast.Core/FrequencyWatch.cs index ea49c2f..539bb13 100644 --- a/src/DotRecast.Core/TickWatch.cs +++ b/src/DotRecast.Core/FrequencyWatch.cs @@ -3,7 +3,7 @@ using System.Diagnostics; namespace DotRecast.Core { - public static class TickWatch + public static class FrequencyWatch { public static readonly double Frequency = (double)TimeSpan.TicksPerSecond / Stopwatch.Frequency; public static long Ticks => unchecked((long)(Stopwatch.GetTimestamp() * Frequency)); diff --git a/src/DotRecast.Detour.Crowd/CrowdTelemetry.cs b/src/DotRecast.Detour.Crowd/CrowdTelemetry.cs index 4e35972..a2823ad 100644 --- a/src/DotRecast.Detour.Crowd/CrowdTelemetry.cs +++ b/src/DotRecast.Detour.Crowd/CrowdTelemetry.cs @@ -66,12 +66,12 @@ namespace DotRecast.Detour.Crowd public void start(string name) { - _executionTimings.Add(name, TickWatch.Ticks); + _executionTimings.Add(name, FrequencyWatch.Ticks); } public void stop(string name) { - long duration = TickWatch.Ticks - _executionTimings[name]; + long duration = FrequencyWatch.Ticks - _executionTimings[name]; if (!_executionTimingSamples.TryGetValue(name, out var s)) { s = new List(); diff --git a/src/DotRecast.Recast.Demo/RecastDemo.cs b/src/DotRecast.Recast.Demo/RecastDemo.cs index a73f679..f4a5ae8 100644 --- a/src/DotRecast.Recast.Demo/RecastDemo.cs +++ b/src/DotRecast.Recast.Demo/RecastDemo.cs @@ -469,7 +469,7 @@ public class RecastDemo cameraPos[1] += (float)((_moveUp - _moveDown) * keySpeed * dt); - long time = TickWatch.Ticks; + long time = FrequencyWatch.Ticks; prevFrameTime = time; // Update sample simulation. @@ -536,7 +536,7 @@ public class RecastDemo float m_detailSampleDist = settingsUI.getDetailSampleDist(); float m_detailSampleMaxError = settingsUI.getDetailSampleMaxError(); int m_tileSize = settingsUI.getTileSize(); - long t = TickWatch.Ticks; + long t = FrequencyWatch.Ticks; Tuple, NavMesh> buildResult; if (settingsUI.isTiled()) @@ -558,7 +558,7 @@ public class RecastDemo sample.update(sample.getInputGeom(), buildResult.Item1, buildResult.Item2); sample.setChanged(false); - settingsUI.setBuildTime((TickWatch.Ticks - t) / TimeSpan.TicksPerMillisecond); + settingsUI.setBuildTime((FrequencyWatch.Ticks - t) / TimeSpan.TicksPerMillisecond); settingsUI.setBuildTelemetry(buildResult.Item1.Select(x => x.getTelemetry()).ToList()); toolsUI.setSample(sample); } diff --git a/src/DotRecast.Recast.Demo/Tools/CrowdProfilingTool.cs b/src/DotRecast.Recast.Demo/Tools/CrowdProfilingTool.cs index 6f6742f..5c2e307 100644 --- a/src/DotRecast.Recast.Demo/Tools/CrowdProfilingTool.cs +++ b/src/DotRecast.Recast.Demo/Tools/CrowdProfilingTool.cs @@ -239,7 +239,7 @@ public class CrowdProfilingTool public void update(float dt) { - long startTime = TickWatch.Ticks; + long startTime = FrequencyWatch.Ticks; if (crowd != null) { crowd.config().pathQueueSize = pathQueueSize; @@ -247,7 +247,7 @@ public class CrowdProfilingTool crowd.update(dt, null); } - long endTime = TickWatch.Ticks; + long endTime = FrequencyWatch.Ticks; if (crowd != null) { NavMeshQuery navquery = new NavMeshQuery(navMesh); diff --git a/src/DotRecast.Recast.Demo/Tools/CrowdTool.cs b/src/DotRecast.Recast.Demo/Tools/CrowdTool.cs index 9a3d564..aa76769 100644 --- a/src/DotRecast.Recast.Demo/Tools/CrowdTool.cs +++ b/src/DotRecast.Recast.Demo/Tools/CrowdTool.cs @@ -678,9 +678,9 @@ public class CrowdTool : Tool if (nav == null) return; - long startTime = TickWatch.Ticks; + long startTime = FrequencyWatch.Ticks; crowd.update(dt, m_agentDebug); - long endTime = TickWatch.Ticks; + long endTime = FrequencyWatch.Ticks; // Update agent trails foreach (CrowdAgent ag in crowd.getActiveAgents()) diff --git a/src/DotRecast.Recast.Demo/Tools/DynamicUpdateTool.cs b/src/DotRecast.Recast.Demo/Tools/DynamicUpdateTool.cs index 127c7c3..2a4f450 100644 --- a/src/DotRecast.Recast.Demo/Tools/DynamicUpdateTool.cs +++ b/src/DotRecast.Recast.Demo/Tools/DynamicUpdateTool.cs @@ -204,9 +204,9 @@ public class DynamicUpdateTool : Tool { Vector3f sp = Vector3f.Of(spos[0], spos[1] + 1.3f, spos[2]); Vector3f ep = Vector3f.Of(epos[0], epos[1] + 1.3f, epos[2]); - long t1 = TickWatch.Ticks; + long t1 = FrequencyWatch.Ticks; float? hitPos = dynaMesh.voxelQuery().raycast(sp, ep); - long t2 = TickWatch.Ticks; + long t2 = FrequencyWatch.Ticks; raycastTime = (t2 - t1) / TimeSpan.TicksPerMillisecond; raycastHit = hitPos.HasValue; raycastHitPos = hitPos.HasValue @@ -498,13 +498,13 @@ public class DynamicUpdateTool : Tool private void updateDynaMesh() { - long t = TickWatch.Ticks; + long t = FrequencyWatch.Ticks; try { bool updated = dynaMesh.update(executor).Result; if (updated) { - buildTime = (TickWatch.Ticks - t) / TimeSpan.TicksPerMillisecond; + buildTime = (FrequencyWatch.Ticks - t) / TimeSpan.TicksPerMillisecond; sample.update(null, dynaMesh.recastResults(), dynaMesh.navMesh()); sample.setChanged(false); } @@ -727,7 +727,7 @@ public class DynamicUpdateTool : Tool private void buildDynaMesh() { configDynaMesh(); - long t = TickWatch.Ticks; + long t = FrequencyWatch.Ticks; try { var _ = dynaMesh.build(executor).Result; @@ -737,7 +737,7 @@ public class DynamicUpdateTool : Tool Console.WriteLine(e); } - buildTime = (TickWatch.Ticks - t) / TimeSpan.TicksPerMillisecond; + buildTime = (FrequencyWatch.Ticks - t) / TimeSpan.TicksPerMillisecond; sample.update(null, dynaMesh.recastResults(), dynaMesh.navMesh()); } diff --git a/src/DotRecast.Recast/Telemetry.cs b/src/DotRecast.Recast/Telemetry.cs index bed10fb..6ae307f 100644 --- a/src/DotRecast.Recast/Telemetry.cs +++ b/src/DotRecast.Recast/Telemetry.cs @@ -33,14 +33,14 @@ namespace DotRecast.Recast public void startTimer(string name) { - timerStart.Value[name] = new AtomicLong(TickWatch.Ticks); + timerStart.Value[name] = new AtomicLong(FrequencyWatch.Ticks); } public void stopTimer(string name) { timerAccum .GetOrAdd(name, _ => new AtomicLong(0)) - .AddAndGet(TickWatch.Ticks - timerStart.Value?[name].Read() ?? 0); + .AddAndGet(FrequencyWatch.Ticks - timerStart.Value?[name].Read() ?? 0); } public void warn(string @string) diff --git a/test/DotRecast.Detour.Test/RandomPointTest.cs b/test/DotRecast.Detour.Test/RandomPointTest.cs index 7c1bcf4..3141502 100644 --- a/test/DotRecast.Detour.Test/RandomPointTest.cs +++ b/test/DotRecast.Detour.Test/RandomPointTest.cs @@ -121,19 +121,19 @@ public class RandomPointTest : AbstractDetourTest query.findRandomPointWithinCircle(point.getRandomRef(), point.getRandomPt(), radius, filter, f); } - long t1 = TickWatch.Ticks; + long t1 = FrequencyWatch.Ticks; for (int i = 0; i < 10000; i++) { query.findRandomPointAroundCircle(point.getRandomRef(), point.getRandomPt(), radius, filter, f); } - long t2 = TickWatch.Ticks; + long t2 = FrequencyWatch.Ticks; for (int i = 0; i < 10000; i++) { query.findRandomPointWithinCircle(point.getRandomRef(), point.getRandomPt(), radius, filter, f); } - long t3 = TickWatch.Ticks; + long t3 = FrequencyWatch.Ticks; Console.WriteLine("Random point around circle: " + (t2 - t1) / TimeSpan.TicksPerMillisecond + "ms"); Console.WriteLine("Random point within circle: " + (t3 - t2) / TimeSpan.TicksPerMillisecond + "ms"); } diff --git a/test/DotRecast.Detour.TileCache.Test/TileCacheTest.cs b/test/DotRecast.Detour.TileCache.Test/TileCacheTest.cs index d480aaa..09b88a9 100644 --- a/test/DotRecast.Detour.TileCache.Test/TileCacheTest.cs +++ b/test/DotRecast.Detour.TileCache.Test/TileCacheTest.cs @@ -188,20 +188,20 @@ public class TileCacheTest : AbstractTileCacheTest layerBuilder.build(order, cCompatibility, threads); } - long t1 = TickWatch.Ticks; + long t1 = FrequencyWatch.Ticks; List layers = null; for (int i = 0; i < 8; i++) { layers = layerBuilder.build(order, cCompatibility, 1); } - long t2 = TickWatch.Ticks; + long t2 = FrequencyWatch.Ticks; for (int i = 0; i < 8; i++) { layers = layerBuilder.build(order, cCompatibility, threads); } - long t3 = TickWatch.Ticks; + long t3 = FrequencyWatch.Ticks; Console.WriteLine(" Time ST : " + (t2 - t1) / TimeSpan.TicksPerMillisecond); Console.WriteLine(" Time MT : " + (t3 - t2) / TimeSpan.TicksPerMillisecond); TileCache tc = getTileCache(geom, order, cCompatibility); diff --git a/test/DotRecast.Recast.Test/RecastSoloMeshTest.cs b/test/DotRecast.Recast.Test/RecastSoloMeshTest.cs index 62f722f..49cea6d 100644 --- a/test/DotRecast.Recast.Test/RecastSoloMeshTest.cs +++ b/test/DotRecast.Recast.Test/RecastSoloMeshTest.cs @@ -96,7 +96,7 @@ public class RecastSoloMeshTest { m_partitionType = partitionType; InputGeomProvider geomProvider = ObjImporter.load(Loader.ToBytes(filename)); - long time = TickWatch.Ticks; + long time = FrequencyWatch.Ticks; Vector3f bmin = geomProvider.getMeshBoundsMin(); Vector3f bmax = geomProvider.getMeshBoundsMax(); Telemetry m_ctx = new Telemetry(); @@ -204,7 +204,7 @@ public class RecastSoloMeshTest // you use tiles) // * good choice to use for tiled navmesh with medium and small sized // tiles - long time3 = TickWatch.Ticks; + long time3 = FrequencyWatch.Ticks; if (m_partitionType == PartitionType.WATERSHED) { @@ -256,7 +256,7 @@ public class RecastSoloMeshTest Assert.That(m_dmesh.nmeshes, Is.EqualTo(expDetMeshes), "Mesh Detail Meshes"); Assert.That(m_dmesh.nverts, Is.EqualTo(expDetVerts), "Mesh Detail Verts"); Assert.That(m_dmesh.ntris, Is.EqualTo(expDetTris), "Mesh Detail Tris"); - long time2 = TickWatch.Ticks; + long time2 = FrequencyWatch.Ticks; Console.WriteLine(filename + " : " + partitionType + " " + (time2 - time) / TimeSpan.TicksPerMillisecond + " ms"); Console.WriteLine(" " + (time3 - time) / TimeSpan.TicksPerMillisecond + " ms"); saveObj(filename.Substring(0, filename.LastIndexOf('.')) + "_" + partitionType + "_detail.obj", m_dmesh); diff --git a/test/DotRecast.Recast.Test/RecastTileMeshTest.cs b/test/DotRecast.Recast.Test/RecastTileMeshTest.cs index 633b032..dd64ef1 100644 --- a/test/DotRecast.Recast.Test/RecastTileMeshTest.cs +++ b/test/DotRecast.Recast.Test/RecastTileMeshTest.cs @@ -106,19 +106,19 @@ public class RecastTileMeshTest build(geom, builder, cfg, 4, true); } - long t1 = TickWatch.Ticks; + long t1 = FrequencyWatch.Ticks; for (int i = 0; i < 4; i++) { build(geom, builder, cfg, 1, false); } - long t2 = TickWatch.Ticks; + long t2 = FrequencyWatch.Ticks; for (int i = 0; i < 4; i++) { build(geom, builder, cfg, 4, false); } - long t3 = TickWatch.Ticks; + long t3 = FrequencyWatch.Ticks; Console.WriteLine(" Time ST : " + (t2 - t1) / TimeSpan.TicksPerMillisecond); Console.WriteLine(" Time MT : " + (t3 - t2) / TimeSpan.TicksPerMillisecond); }