private void Benchmark(double holeDilationRadius) { void RunBenchmarkIteration() { TerrainService.SnapshotCompiler.InvalidateCaches(); TerrainService.CompileSnapshot().OverlayNetworkManager.CompileTerrainOverlayNetwork(holeDilationRadius); } for (var i = 0; i < 10; i++) { RunBenchmarkIteration(); if (i == 0) { PolyNodeCrossoverPointManager.DumpPerformanceCounters(); } } GC.Collect(); var sw = new Stopwatch(); sw.Start(); for (var i = 0; i < 10; i++) { RunBenchmarkIteration(); } Console.WriteLine("10itr: " + sw.ElapsedMilliseconds + "ms"); }
public TerrainOverlayNetworkNode(SectorNodeDescription sectorNodeDescription, LocalGeometryView localGeometryView, PolyNode landPolyNode) { SectorNodeDescription = sectorNodeDescription; LocalGeometryView = localGeometryView; LandPolyNode = landPolyNode; CrossoverPointManager = new PolyNodeCrossoverPointManager(landPolyNode); }
public static void Main(string[] args) { var sectorMetadataPresets = SectorMetadataPresets.HashCircle2; var terrainStaticMetadata = new TerrainStaticMetadata { LocalBoundary = sectorMetadataPresets.LocalBoundary, LocalIncludedContours = sectorMetadataPresets.LocalIncludedContours, LocalExcludedContours = sectorMetadataPresets.LocalExcludedContours }; var(localGeometryView, landPolyNode, crossoverPointManager) = BenchmarkAddCrossoverPoints(terrainStaticMetadata); var canvas = host.CreateAndAddCanvas(0); canvas.Transform = Matrix4x4.CreateScale(1000 / 60000.0f) * Matrix4x4.CreateTranslation(500, 500, 0); canvas.DrawPolyNode((PolyTree)landPolyNode.Parent); canvas.DrawVisibilityGraph(landPolyNode.ComputeVisibilityGraph()); canvas.DrawLineList(landPolyNode.FindContourAndChildHoleBarriers(), StrokeStyle.BlackHairLineSolid); canvas.DrawPoints(crossoverPointManager.CrossoverPoints, StrokeStyle.RedThick5Solid); // var a = landPolyNode.FindAggregateContourCrossoverWaypoints()[6]; // var b = landPolyNode.FindAggregateContourCrossoverWaypoints()[13]; // var q = new IntLineSegment2(a, b); // canvas.DrawPoint(a, StrokeStyle.RedThick5Solid); // canvas.DrawPoint(b, StrokeStyle.RedThick5Solid); // var bvh = landPolyNode.FindContourAndChildHoleBarriersBvh(); // canvas.DrawBvh(bvh); // foreach (var (i, val) in bvh.BoundingBoxes.Enumerate()) { // if (val.Intersects(q)) Console.WriteLine(i + " " + val); // } // var intersects = bvh.Intersects(q); // canvas.DrawLine(a, b, intersects ? StrokeStyle.RedHairLineSolid : StrokeStyle.LimeHairLineSolid); PolyNodeCrossoverPointManager.DumpPerformanceCounters(); while (true) { const int ntrials = 10; var sw = new Stopwatch(); sw.Start(); for (var i = 0; i < ntrials; i++) { BenchmarkAddCrossoverPoints(terrainStaticMetadata); } Console.WriteLine($"{ntrials} trials in {sw.ElapsedMilliseconds} ms"); } }