diff options
Diffstat (limited to 'OpenSim/Tests/Performance/ObjectPerformanceTests.cs')
-rw-r--r-- | OpenSim/Tests/Performance/ObjectPerformanceTests.cs | 174 |
1 files changed, 174 insertions, 0 deletions
diff --git a/OpenSim/Tests/Performance/ObjectPerformanceTests.cs b/OpenSim/Tests/Performance/ObjectPerformanceTests.cs new file mode 100644 index 0000000..9dad423 --- /dev/null +++ b/OpenSim/Tests/Performance/ObjectPerformanceTests.cs | |||
@@ -0,0 +1,174 @@ | |||
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 | |||
38 | namespace OpenSim.Tests.Performance | ||
39 | { | ||
40 | /// <summary> | ||
41 | /// Object performance tests | ||
42 | /// </summary> | ||
43 | /// <remarks> | ||
44 | /// Don't rely on the numbers given by these tests - they will vary a lot depending on what is already cached, | ||
45 | /// how much memory is free, etc. In some cases, later larger tests will apparently take less time than smaller | ||
46 | /// earlier tests. | ||
47 | /// </remarks> | ||
48 | [TestFixture] | ||
49 | public class ObjectPerformanceTests : OpenSimTestCase | ||
50 | { | ||
51 | [TearDown] | ||
52 | public void TearDown() | ||
53 | { | ||
54 | GC.Collect(); | ||
55 | GC.WaitForPendingFinalizers(); | ||
56 | } | ||
57 | |||
58 | // [Test] | ||
59 | // public void Test0000Clean() | ||
60 | // { | ||
61 | // TestHelpers.InMethod(); | ||
62 | //// log4net.Config.XmlConfigurator.Configure(); | ||
63 | // | ||
64 | // TestAddObjects(200000); | ||
65 | // } | ||
66 | |||
67 | [Test] | ||
68 | public void Test_0001_10K_1PrimObjects() | ||
69 | { | ||
70 | TestHelpers.InMethod(); | ||
71 | // log4net.Config.XmlConfigurator.Configure(); | ||
72 | |||
73 | TestAddObjects(1, 10000); | ||
74 | } | ||
75 | |||
76 | [Test] | ||
77 | public void Test_0002_100K_1PrimObjects() | ||
78 | { | ||
79 | TestHelpers.InMethod(); | ||
80 | // log4net.Config.XmlConfigurator.Configure(); | ||
81 | |||
82 | TestAddObjects(1, 100000); | ||
83 | } | ||
84 | |||
85 | [Test] | ||
86 | public void Test_0003_200K_1PrimObjects() | ||
87 | { | ||
88 | TestHelpers.InMethod(); | ||
89 | // log4net.Config.XmlConfigurator.Configure(); | ||
90 | |||
91 | TestAddObjects(1, 200000); | ||
92 | } | ||
93 | |||
94 | [Test] | ||
95 | public void Test_0011_100_100PrimObjects() | ||
96 | { | ||
97 | TestHelpers.InMethod(); | ||
98 | // log4net.Config.XmlConfigurator.Configure(); | ||
99 | |||
100 | TestAddObjects(100, 100); | ||
101 | } | ||
102 | |||
103 | [Test] | ||
104 | public void Test_0012_1K_100PrimObjects() | ||
105 | { | ||
106 | TestHelpers.InMethod(); | ||
107 | // log4net.Config.XmlConfigurator.Configure(); | ||
108 | |||
109 | TestAddObjects(100, 1000); | ||
110 | } | ||
111 | |||
112 | [Test] | ||
113 | public void Test_0013_2K_100PrimObjects() | ||
114 | { | ||
115 | TestHelpers.InMethod(); | ||
116 | // log4net.Config.XmlConfigurator.Configure(); | ||
117 | |||
118 | TestAddObjects(100, 2000); | ||
119 | } | ||
120 | |||
121 | private void TestAddObjects(int primsInEachObject, int objectsToAdd) | ||
122 | { | ||
123 | UUID ownerId = new UUID("F0000000-0000-0000-0000-000000000000"); | ||
124 | |||
125 | // Using a local variable for scene, at least on mono 2.6.7, means that it's much more likely to be garbage | ||
126 | // collected when we teardown this test. If it's done in a member variable, even if that is subsequently | ||
127 | // nulled out, the garbage collect can be delayed. | ||
128 | TestScene scene = new SceneHelpers().SetupScene(); | ||
129 | |||
130 | // Process process = Process.GetCurrentProcess(); | ||
131 | // long startProcessMemory = process.PrivateMemorySize64; | ||
132 | long startGcMemory = GC.GetTotalMemory(true); | ||
133 | DateTime start = DateTime.Now; | ||
134 | |||
135 | for (int i = 1; i <= objectsToAdd; i++) | ||
136 | { | ||
137 | SceneObjectGroup so = SceneHelpers.CreateSceneObject(primsInEachObject, ownerId, "part_", i); | ||
138 | Assert.That(scene.AddNewSceneObject(so, false), Is.True, string.Format("Object {0} was not created", i)); | ||
139 | } | ||
140 | |||
141 | TimeSpan elapsed = DateTime.Now - start; | ||
142 | // long processMemoryAlloc = process.PrivateMemorySize64 - startProcessMemory; | ||
143 | long endGcMemory = GC.GetTotalMemory(false); | ||
144 | |||
145 | for (int i = 1; i <= objectsToAdd; i++) | ||
146 | { | ||
147 | Assert.That( | ||
148 | scene.GetSceneObjectGroup(TestHelpers.ParseTail(i)), | ||
149 | Is.Not.Null, | ||
150 | string.Format("Object {0} could not be retrieved", i)); | ||
151 | } | ||
152 | |||
153 | // When a scene object is added to a scene, it is placed in the update list for sending to viewers | ||
154 | // (though in this case we have none). When it is deleted, it is not removed from the update which is | ||
155 | // fine since it will later be ignored. | ||
156 | // | ||
157 | // However, that means that we need to manually run an update here to clear out that list so that deleted | ||
158 | // objects will be clean up by the garbage collector before the next stress test is run. | ||
159 | scene.Update(1); | ||
160 | |||
161 | Console.WriteLine( | ||
162 | "Took {0}ms, {1}MB ({2} - {3}) to create {4} objects each containing {5} prim(s)", | ||
163 | Math.Round(elapsed.TotalMilliseconds), | ||
164 | (endGcMemory - startGcMemory) / 1024 / 1024, | ||
165 | endGcMemory / 1024 / 1024, | ||
166 | startGcMemory / 1024 / 1024, | ||
167 | objectsToAdd, | ||
168 | primsInEachObject); | ||
169 | |||
170 | scene.Close(); | ||
171 | // scene = null; | ||
172 | } | ||
173 | } | ||
174 | } \ No newline at end of file | ||