clockwerk-opensim-stable – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 vero 1 /*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27  
28 using System;
29 using System.Diagnostics;
30 using System.Reflection;
31 using log4net;
32 using NUnit.Framework;
33 using OpenMetaverse;
34 using OpenSim.Framework;
35 using OpenSim.Region.Framework.Scenes;
36 using OpenSim.Tests.Common;
37 using OpenSim.Tests.Common.Mock;
38  
39 namespace OpenSim.Tests.Performance
40 {
41 /// <summary>
42 /// Object performance tests
43 /// </summary>
44 /// <remarks>
45 /// Don't rely on the numbers given by these tests - they will vary a lot depending on what is already cached,
46 /// how much memory is free, etc. In some cases, later larger tests will apparently take less time than smaller
47 /// earlier tests.
48 /// </remarks>
49 [TestFixture]
50 public class ObjectPerformanceTests : OpenSimTestCase
51 {
52 [TearDown]
53 public void TearDown()
54 {
55 GC.Collect();
56 GC.WaitForPendingFinalizers();
57 }
58  
59 // [Test]
60 // public void Test0000Clean()
61 // {
62 // TestHelpers.InMethod();
63 //// log4net.Config.XmlConfigurator.Configure();
64 //
65 // TestAddObjects(200000);
66 // }
67  
68 [Test]
69 public void Test_0001_10K_1PrimObjects()
70 {
71 TestHelpers.InMethod();
72 // log4net.Config.XmlConfigurator.Configure();
73  
74 TestAddObjects(1, 10000);
75 }
76  
77 [Test]
78 public void Test_0002_100K_1PrimObjects()
79 {
80 TestHelpers.InMethod();
81 // log4net.Config.XmlConfigurator.Configure();
82  
83 TestAddObjects(1, 100000);
84 }
85  
86 [Test]
87 public void Test_0003_200K_1PrimObjects()
88 {
89 TestHelpers.InMethod();
90 // log4net.Config.XmlConfigurator.Configure();
91  
92 TestAddObjects(1, 200000);
93 }
94  
95 [Test]
96 public void Test_0011_100_100PrimObjects()
97 {
98 TestHelpers.InMethod();
99 // log4net.Config.XmlConfigurator.Configure();
100  
101 TestAddObjects(100, 100);
102 }
103  
104 [Test]
105 public void Test_0012_1K_100PrimObjects()
106 {
107 TestHelpers.InMethod();
108 // log4net.Config.XmlConfigurator.Configure();
109  
110 TestAddObjects(100, 1000);
111 }
112  
113 [Test]
114 public void Test_0013_2K_100PrimObjects()
115 {
116 TestHelpers.InMethod();
117 // log4net.Config.XmlConfigurator.Configure();
118  
119 TestAddObjects(100, 2000);
120 }
121  
122 private void TestAddObjects(int primsInEachObject, int objectsToAdd)
123 {
124 UUID ownerId = new UUID("F0000000-0000-0000-0000-000000000000");
125  
126 // Using a local variable for scene, at least on mono 2.6.7, means that it's much more likely to be garbage
127 // collected when we teardown this test. If it's done in a member variable, even if that is subsequently
128 // nulled out, the garbage collect can be delayed.
129 TestScene scene = new SceneHelpers().SetupScene();
130  
131 // Process process = Process.GetCurrentProcess();
132 // long startProcessMemory = process.PrivateMemorySize64;
133 long startGcMemory = GC.GetTotalMemory(true);
134 DateTime start = DateTime.Now;
135  
136 for (int i = 1; i <= objectsToAdd; i++)
137 {
138 SceneObjectGroup so = SceneHelpers.CreateSceneObject(primsInEachObject, ownerId, "part_", i);
139 Assert.That(scene.AddNewSceneObject(so, false), Is.True, string.Format("Object {0} was not created", i));
140 }
141  
142 TimeSpan elapsed = DateTime.Now - start;
143 // long processMemoryAlloc = process.PrivateMemorySize64 - startProcessMemory;
144 long endGcMemory = GC.GetTotalMemory(false);
145  
146 for (int i = 1; i <= objectsToAdd; i++)
147 {
148 Assert.That(
149 scene.GetSceneObjectGroup(TestHelpers.ParseTail(i)),
150 Is.Not.Null,
151 string.Format("Object {0} could not be retrieved", i));
152 }
153  
154 // When a scene object is added to a scene, it is placed in the update list for sending to viewers
155 // (though in this case we have none). When it is deleted, it is not removed from the update which is
156 // fine since it will later be ignored.
157 //
158 // However, that means that we need to manually run an update here to clear out that list so that deleted
159 // objects will be clean up by the garbage collector before the next stress test is run.
160 scene.Update(1);
161  
162 Console.WriteLine(
163 "Took {0}ms, {1}MB ({2} - {3}) to create {4} objects each containing {5} prim(s)",
164 Math.Round(elapsed.TotalMilliseconds),
165 (endGcMemory - startGcMemory) / 1024 / 1024,
166 endGcMemory / 1024 / 1024,
167 startGcMemory / 1024 / 1024,
168 objectsToAdd,
169 primsInEachObject);
170  
171 scene.Close();
172 // scene = null;
173 }
174 }
175 }