Exemplo n.º 1
0
        public void TestUpdateScene()
        {
            TestHelpers.InMethod();

            Scene scene = new SceneHelpers().SetupScene();
            scene.Update(1);
            
            Assert.That(scene.Frame, Is.EqualTo(1));
        }
Exemplo n.º 2
0
        public void TestShutdownScene()
        {
            TestHelpers.InMethod();

            Scene scene = new SceneHelpers().SetupScene();
            scene.Close();

            Assert.That(scene.ShuttingDown, Is.True);
            Assert.That(scene.Active, Is.False);

            // Trying to update a shutdown scene should result in no update
            scene.Update(1);

            Assert.That(scene.Frame, Is.EqualTo(0));
        }
Exemplo n.º 3
0
        private void TestAddObjects(int primsInEachObject, int objectsToAdd)
        {
            UUID ownerId = new UUID("F0000000-0000-0000-0000-000000000000");

            // Using a local variable for scene, at least on mono 2.6.7, means that it's much more likely to be garbage
            // collected when we teardown this test.  If it's done in a member variable, even if that is subsequently
            // nulled out, the garbage collect can be delayed.
            TestScene scene = new SceneHelpers().SetupScene();

//            Process process = Process.GetCurrentProcess();
//            long startProcessMemory = process.PrivateMemorySize64;
            long startGcMemory = GC.GetTotalMemory(true);
            DateTime start = DateTime.Now;

            for (int i = 1; i <= objectsToAdd; i++)
            {
                SceneObjectGroup so = SceneHelpers.CreateSceneObject(primsInEachObject, ownerId, "part_", i);
                Assert.That(scene.AddNewSceneObject(so, false), Is.True, string.Format("Object {0} was not created", i));
            }

            TimeSpan elapsed = DateTime.Now - start;
//            long processMemoryAlloc = process.PrivateMemorySize64 - startProcessMemory;
            long endGcMemory = GC.GetTotalMemory(false);

            for (int i = 1; i <= objectsToAdd; i++)
            {
                Assert.That(
                    scene.GetSceneObjectGroup(TestHelpers.ParseTail(i)),
                    Is.Not.Null,
                    string.Format("Object {0} could not be retrieved", i));
            }

            // When a scene object is added to a scene, it is placed in the update list for sending to viewers
            // (though in this case we have none).  When it is deleted, it is not removed from the update which is
            // fine since it will later be ignored.
            //
            // However, that means that we need to manually run an update here to clear out that list so that deleted
            // objects will be clean up by the garbage collector before the next stress test is run.
            scene.Update(1);

            Console.WriteLine(
                "Took {0}ms, {1}MB ({2} - {3}) to create {4} objects each containing {5} prim(s)",
                Math.Round(elapsed.TotalMilliseconds),
                (endGcMemory - startGcMemory) / 1024 / 1024,
                endGcMemory / 1024 / 1024,
                startGcMemory / 1024 / 1024,
                objectsToAdd,
                primsInEachObject);

            scene.Close();
//            scene = null;
        }