forked from mirror/DotRecast
rename FrequencyWatch
This commit is contained in:
parent
7b820fafd7
commit
f9782da010
|
@ -3,7 +3,7 @@ using System.Diagnostics;
|
||||||
|
|
||||||
namespace DotRecast.Core
|
namespace DotRecast.Core
|
||||||
{
|
{
|
||||||
public static class TickWatch
|
public static class FrequencyWatch
|
||||||
{
|
{
|
||||||
public static readonly double Frequency = (double)TimeSpan.TicksPerSecond / Stopwatch.Frequency;
|
public static readonly double Frequency = (double)TimeSpan.TicksPerSecond / Stopwatch.Frequency;
|
||||||
public static long Ticks => unchecked((long)(Stopwatch.GetTimestamp() * Frequency));
|
public static long Ticks => unchecked((long)(Stopwatch.GetTimestamp() * Frequency));
|
|
@ -66,12 +66,12 @@ namespace DotRecast.Detour.Crowd
|
||||||
|
|
||||||
public void start(string name)
|
public void start(string name)
|
||||||
{
|
{
|
||||||
_executionTimings.Add(name, TickWatch.Ticks);
|
_executionTimings.Add(name, FrequencyWatch.Ticks);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stop(string name)
|
public void stop(string name)
|
||||||
{
|
{
|
||||||
long duration = TickWatch.Ticks - _executionTimings[name];
|
long duration = FrequencyWatch.Ticks - _executionTimings[name];
|
||||||
if (!_executionTimingSamples.TryGetValue(name, out var s))
|
if (!_executionTimingSamples.TryGetValue(name, out var s))
|
||||||
{
|
{
|
||||||
s = new List<long>();
|
s = new List<long>();
|
||||||
|
|
|
@ -469,7 +469,7 @@ public class RecastDemo
|
||||||
|
|
||||||
cameraPos[1] += (float)((_moveUp - _moveDown) * keySpeed * dt);
|
cameraPos[1] += (float)((_moveUp - _moveDown) * keySpeed * dt);
|
||||||
|
|
||||||
long time = TickWatch.Ticks;
|
long time = FrequencyWatch.Ticks;
|
||||||
prevFrameTime = time;
|
prevFrameTime = time;
|
||||||
|
|
||||||
// Update sample simulation.
|
// Update sample simulation.
|
||||||
|
@ -536,7 +536,7 @@ public class RecastDemo
|
||||||
float m_detailSampleDist = settingsUI.getDetailSampleDist();
|
float m_detailSampleDist = settingsUI.getDetailSampleDist();
|
||||||
float m_detailSampleMaxError = settingsUI.getDetailSampleMaxError();
|
float m_detailSampleMaxError = settingsUI.getDetailSampleMaxError();
|
||||||
int m_tileSize = settingsUI.getTileSize();
|
int m_tileSize = settingsUI.getTileSize();
|
||||||
long t = TickWatch.Ticks;
|
long t = FrequencyWatch.Ticks;
|
||||||
|
|
||||||
Tuple<IList<RecastBuilderResult>, NavMesh> buildResult;
|
Tuple<IList<RecastBuilderResult>, NavMesh> buildResult;
|
||||||
if (settingsUI.isTiled())
|
if (settingsUI.isTiled())
|
||||||
|
@ -558,7 +558,7 @@ public class RecastDemo
|
||||||
|
|
||||||
sample.update(sample.getInputGeom(), buildResult.Item1, buildResult.Item2);
|
sample.update(sample.getInputGeom(), buildResult.Item1, buildResult.Item2);
|
||||||
sample.setChanged(false);
|
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());
|
settingsUI.setBuildTelemetry(buildResult.Item1.Select(x => x.getTelemetry()).ToList());
|
||||||
toolsUI.setSample(sample);
|
toolsUI.setSample(sample);
|
||||||
}
|
}
|
||||||
|
|
|
@ -239,7 +239,7 @@ public class CrowdProfilingTool
|
||||||
|
|
||||||
public void update(float dt)
|
public void update(float dt)
|
||||||
{
|
{
|
||||||
long startTime = TickWatch.Ticks;
|
long startTime = FrequencyWatch.Ticks;
|
||||||
if (crowd != null)
|
if (crowd != null)
|
||||||
{
|
{
|
||||||
crowd.config().pathQueueSize = pathQueueSize;
|
crowd.config().pathQueueSize = pathQueueSize;
|
||||||
|
@ -247,7 +247,7 @@ public class CrowdProfilingTool
|
||||||
crowd.update(dt, null);
|
crowd.update(dt, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
long endTime = TickWatch.Ticks;
|
long endTime = FrequencyWatch.Ticks;
|
||||||
if (crowd != null)
|
if (crowd != null)
|
||||||
{
|
{
|
||||||
NavMeshQuery navquery = new NavMeshQuery(navMesh);
|
NavMeshQuery navquery = new NavMeshQuery(navMesh);
|
||||||
|
|
|
@ -678,9 +678,9 @@ public class CrowdTool : Tool
|
||||||
if (nav == null)
|
if (nav == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
long startTime = TickWatch.Ticks;
|
long startTime = FrequencyWatch.Ticks;
|
||||||
crowd.update(dt, m_agentDebug);
|
crowd.update(dt, m_agentDebug);
|
||||||
long endTime = TickWatch.Ticks;
|
long endTime = FrequencyWatch.Ticks;
|
||||||
|
|
||||||
// Update agent trails
|
// Update agent trails
|
||||||
foreach (CrowdAgent ag in crowd.getActiveAgents())
|
foreach (CrowdAgent ag in crowd.getActiveAgents())
|
||||||
|
|
|
@ -204,9 +204,9 @@ public class DynamicUpdateTool : Tool
|
||||||
{
|
{
|
||||||
Vector3f sp = Vector3f.Of(spos[0], spos[1] + 1.3f, spos[2]);
|
Vector3f sp = Vector3f.Of(spos[0], spos[1] + 1.3f, spos[2]);
|
||||||
Vector3f ep = Vector3f.Of(epos[0], epos[1] + 1.3f, epos[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);
|
float? hitPos = dynaMesh.voxelQuery().raycast(sp, ep);
|
||||||
long t2 = TickWatch.Ticks;
|
long t2 = FrequencyWatch.Ticks;
|
||||||
raycastTime = (t2 - t1) / TimeSpan.TicksPerMillisecond;
|
raycastTime = (t2 - t1) / TimeSpan.TicksPerMillisecond;
|
||||||
raycastHit = hitPos.HasValue;
|
raycastHit = hitPos.HasValue;
|
||||||
raycastHitPos = hitPos.HasValue
|
raycastHitPos = hitPos.HasValue
|
||||||
|
@ -498,13 +498,13 @@ public class DynamicUpdateTool : Tool
|
||||||
|
|
||||||
private void updateDynaMesh()
|
private void updateDynaMesh()
|
||||||
{
|
{
|
||||||
long t = TickWatch.Ticks;
|
long t = FrequencyWatch.Ticks;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
bool updated = dynaMesh.update(executor).Result;
|
bool updated = dynaMesh.update(executor).Result;
|
||||||
if (updated)
|
if (updated)
|
||||||
{
|
{
|
||||||
buildTime = (TickWatch.Ticks - t) / TimeSpan.TicksPerMillisecond;
|
buildTime = (FrequencyWatch.Ticks - t) / TimeSpan.TicksPerMillisecond;
|
||||||
sample.update(null, dynaMesh.recastResults(), dynaMesh.navMesh());
|
sample.update(null, dynaMesh.recastResults(), dynaMesh.navMesh());
|
||||||
sample.setChanged(false);
|
sample.setChanged(false);
|
||||||
}
|
}
|
||||||
|
@ -727,7 +727,7 @@ public class DynamicUpdateTool : Tool
|
||||||
private void buildDynaMesh()
|
private void buildDynaMesh()
|
||||||
{
|
{
|
||||||
configDynaMesh();
|
configDynaMesh();
|
||||||
long t = TickWatch.Ticks;
|
long t = FrequencyWatch.Ticks;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var _ = dynaMesh.build(executor).Result;
|
var _ = dynaMesh.build(executor).Result;
|
||||||
|
@ -737,7 +737,7 @@ public class DynamicUpdateTool : Tool
|
||||||
Console.WriteLine(e);
|
Console.WriteLine(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
buildTime = (TickWatch.Ticks - t) / TimeSpan.TicksPerMillisecond;
|
buildTime = (FrequencyWatch.Ticks - t) / TimeSpan.TicksPerMillisecond;
|
||||||
sample.update(null, dynaMesh.recastResults(), dynaMesh.navMesh());
|
sample.update(null, dynaMesh.recastResults(), dynaMesh.navMesh());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,14 +33,14 @@ namespace DotRecast.Recast
|
||||||
|
|
||||||
public void startTimer(string name)
|
public void startTimer(string name)
|
||||||
{
|
{
|
||||||
timerStart.Value[name] = new AtomicLong(TickWatch.Ticks);
|
timerStart.Value[name] = new AtomicLong(FrequencyWatch.Ticks);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stopTimer(string name)
|
public void stopTimer(string name)
|
||||||
{
|
{
|
||||||
timerAccum
|
timerAccum
|
||||||
.GetOrAdd(name, _ => new AtomicLong(0))
|
.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)
|
public void warn(string @string)
|
||||||
|
|
|
@ -121,19 +121,19 @@ public class RandomPointTest : AbstractDetourTest
|
||||||
query.findRandomPointWithinCircle(point.getRandomRef(), point.getRandomPt(), radius, filter, f);
|
query.findRandomPointWithinCircle(point.getRandomRef(), point.getRandomPt(), radius, filter, f);
|
||||||
}
|
}
|
||||||
|
|
||||||
long t1 = TickWatch.Ticks;
|
long t1 = FrequencyWatch.Ticks;
|
||||||
for (int i = 0; i < 10000; i++)
|
for (int i = 0; i < 10000; i++)
|
||||||
{
|
{
|
||||||
query.findRandomPointAroundCircle(point.getRandomRef(), point.getRandomPt(), radius, filter, f);
|
query.findRandomPointAroundCircle(point.getRandomRef(), point.getRandomPt(), radius, filter, f);
|
||||||
}
|
}
|
||||||
|
|
||||||
long t2 = TickWatch.Ticks;
|
long t2 = FrequencyWatch.Ticks;
|
||||||
for (int i = 0; i < 10000; i++)
|
for (int i = 0; i < 10000; i++)
|
||||||
{
|
{
|
||||||
query.findRandomPointWithinCircle(point.getRandomRef(), point.getRandomPt(), radius, filter, f);
|
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 around circle: " + (t2 - t1) / TimeSpan.TicksPerMillisecond + "ms");
|
||||||
Console.WriteLine("Random point within circle: " + (t3 - t2) / TimeSpan.TicksPerMillisecond + "ms");
|
Console.WriteLine("Random point within circle: " + (t3 - t2) / TimeSpan.TicksPerMillisecond + "ms");
|
||||||
}
|
}
|
||||||
|
|
|
@ -188,20 +188,20 @@ public class TileCacheTest : AbstractTileCacheTest
|
||||||
layerBuilder.build(order, cCompatibility, threads);
|
layerBuilder.build(order, cCompatibility, threads);
|
||||||
}
|
}
|
||||||
|
|
||||||
long t1 = TickWatch.Ticks;
|
long t1 = FrequencyWatch.Ticks;
|
||||||
List<byte[]> layers = null;
|
List<byte[]> layers = null;
|
||||||
for (int i = 0; i < 8; i++)
|
for (int i = 0; i < 8; i++)
|
||||||
{
|
{
|
||||||
layers = layerBuilder.build(order, cCompatibility, 1);
|
layers = layerBuilder.build(order, cCompatibility, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
long t2 = TickWatch.Ticks;
|
long t2 = FrequencyWatch.Ticks;
|
||||||
for (int i = 0; i < 8; i++)
|
for (int i = 0; i < 8; i++)
|
||||||
{
|
{
|
||||||
layers = layerBuilder.build(order, cCompatibility, threads);
|
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 ST : " + (t2 - t1) / TimeSpan.TicksPerMillisecond);
|
||||||
Console.WriteLine(" Time MT : " + (t3 - t2) / TimeSpan.TicksPerMillisecond);
|
Console.WriteLine(" Time MT : " + (t3 - t2) / TimeSpan.TicksPerMillisecond);
|
||||||
TileCache tc = getTileCache(geom, order, cCompatibility);
|
TileCache tc = getTileCache(geom, order, cCompatibility);
|
||||||
|
|
|
@ -96,7 +96,7 @@ public class RecastSoloMeshTest
|
||||||
{
|
{
|
||||||
m_partitionType = partitionType;
|
m_partitionType = partitionType;
|
||||||
InputGeomProvider geomProvider = ObjImporter.load(Loader.ToBytes(filename));
|
InputGeomProvider geomProvider = ObjImporter.load(Loader.ToBytes(filename));
|
||||||
long time = TickWatch.Ticks;
|
long time = FrequencyWatch.Ticks;
|
||||||
Vector3f bmin = geomProvider.getMeshBoundsMin();
|
Vector3f bmin = geomProvider.getMeshBoundsMin();
|
||||||
Vector3f bmax = geomProvider.getMeshBoundsMax();
|
Vector3f bmax = geomProvider.getMeshBoundsMax();
|
||||||
Telemetry m_ctx = new Telemetry();
|
Telemetry m_ctx = new Telemetry();
|
||||||
|
@ -204,7 +204,7 @@ public class RecastSoloMeshTest
|
||||||
// you use tiles)
|
// you use tiles)
|
||||||
// * good choice to use for tiled navmesh with medium and small sized
|
// * good choice to use for tiled navmesh with medium and small sized
|
||||||
// tiles
|
// tiles
|
||||||
long time3 = TickWatch.Ticks;
|
long time3 = FrequencyWatch.Ticks;
|
||||||
|
|
||||||
if (m_partitionType == PartitionType.WATERSHED)
|
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.nmeshes, Is.EqualTo(expDetMeshes), "Mesh Detail Meshes");
|
||||||
Assert.That(m_dmesh.nverts, Is.EqualTo(expDetVerts), "Mesh Detail Verts");
|
Assert.That(m_dmesh.nverts, Is.EqualTo(expDetVerts), "Mesh Detail Verts");
|
||||||
Assert.That(m_dmesh.ntris, Is.EqualTo(expDetTris), "Mesh Detail Tris");
|
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(filename + " : " + partitionType + " " + (time2 - time) / TimeSpan.TicksPerMillisecond + " ms");
|
||||||
Console.WriteLine(" " + (time3 - time) / TimeSpan.TicksPerMillisecond + " ms");
|
Console.WriteLine(" " + (time3 - time) / TimeSpan.TicksPerMillisecond + " ms");
|
||||||
saveObj(filename.Substring(0, filename.LastIndexOf('.')) + "_" + partitionType + "_detail.obj", m_dmesh);
|
saveObj(filename.Substring(0, filename.LastIndexOf('.')) + "_" + partitionType + "_detail.obj", m_dmesh);
|
||||||
|
|
|
@ -106,19 +106,19 @@ public class RecastTileMeshTest
|
||||||
build(geom, builder, cfg, 4, true);
|
build(geom, builder, cfg, 4, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
long t1 = TickWatch.Ticks;
|
long t1 = FrequencyWatch.Ticks;
|
||||||
for (int i = 0; i < 4; i++)
|
for (int i = 0; i < 4; i++)
|
||||||
{
|
{
|
||||||
build(geom, builder, cfg, 1, false);
|
build(geom, builder, cfg, 1, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
long t2 = TickWatch.Ticks;
|
long t2 = FrequencyWatch.Ticks;
|
||||||
for (int i = 0; i < 4; i++)
|
for (int i = 0; i < 4; i++)
|
||||||
{
|
{
|
||||||
build(geom, builder, cfg, 4, false);
|
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 ST : " + (t2 - t1) / TimeSpan.TicksPerMillisecond);
|
||||||
Console.WriteLine(" Time MT : " + (t3 - t2) / TimeSpan.TicksPerMillisecond);
|
Console.WriteLine(" Time MT : " + (t3 - t2) / TimeSpan.TicksPerMillisecond);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue