static PerformanceResult RunTestForGraph(WorldGraph graph)
        {
            var       result = new PerformanceResult();
            Stopwatch sw     = new Stopwatch();

            result.name = graph.name;

            sw.Start();
            graph.ProcessOnce();
            sw.Stop();
            result.processOnceTime = sw.Elapsed.TotalMilliseconds;

            sw.Reset();
            sw.Start();

            graph.Process();

            sw.Stop();
            result.processTime = sw.Elapsed.TotalMilliseconds;

            result.nodeProcessTime = new NodeProcessTime[graph.allNodes.Count()];
            for (int i = 0; i < result.nodeProcessTime.Length; i++)
            {
                var node = graph.allNodes.ElementAt(i);
                result.nodeProcessTime[i] = new NodeProcessTime(node.name, node.processTime);
            }

            result.totalAllocatedMemory      = Profiler.GetTotalAllocatedMemoryLong();
            result.totalReservedMemory       = Profiler.GetTotalReservedMemoryLong();
            result.totalUnusedReservedMemory = Profiler.GetTotalUnusedReservedMemoryLong();

            return(result);
        }
Beispiel #2
0
        public static void CloneWorldGraphTest()
        {
            WorldGraph worldGraph  = TestUtils.GenerateTestWorldGraph();
            WorldGraph clonedGraph = worldGraph.Clone() as WorldGraph;

            Assert.That(worldGraph.nodes.Count == clonedGraph.nodes.Count);
            Assert.That(worldGraph.allNodes.Count() == clonedGraph.allNodes.Count());
            Assert.That(worldGraph.nodeLinkTable.GetLinks().Count() == clonedGraph.nodeLinkTable.GetLinks().Count());

            foreach (var node in clonedGraph.allNodes)
            {
                Assert.That(worldGraph.allNodes.Contains(node) == false);
            }

            foreach (var node in clonedGraph.allNodes)
            {
                foreach (var anchorField in node.anchorFields)
                {
                    foreach (var anchor in anchorField.anchors)
                    {
                        foreach (var link in anchor.links)
                        {
                            Assert.That(link.toNode != null);
                            Assert.That(link.fromNode != null);

                            Assert.That(clonedGraph.FindNodeById(link.toNode.id) != null);
                            Assert.That(clonedGraph.FindNodeById(link.fromNode.id) != null);

                            Assert.That(worldGraph.allNodes.Contains(link.fromNode) == false);
                            Assert.That(worldGraph.allNodes.Contains(link.toNode) == false);
                        }
                    }
                }
            }

            Assert.That(clonedGraph.readyToProcess == true);

            clonedGraph.Process();
        }