aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Tests/Performance
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2012-08-29 23:19:21 +0100
committerJustin Clark-Casey (justincc)2012-08-29 23:19:21 +0100
commitadce58b33a39c9456468f6d25834a8a7bded5adf (patch)
tree1594f527c86722454829c9a3367e40e19800f2d7 /OpenSim/Tests/Performance
parentMerge branch 'master' of ssh://opensimulator.org/var/git/opensim (diff)
downloadopensim-SC_OLD-adce58b33a39c9456468f6d25834a8a7bded5adf.zip
opensim-SC_OLD-adce58b33a39c9456468f6d25834a8a7bded5adf.tar.gz
opensim-SC_OLD-adce58b33a39c9456468f6d25834a8a7bded5adf.tar.bz2
opensim-SC_OLD-adce58b33a39c9456468f6d25834a8a7bded5adf.tar.xz
Renaming existing 'torture' tests to 'performance' tests instead, since this better matches what they really do.
nant target name changes to test-perf instead of torture, to match test-stress still not run by default
Diffstat (limited to 'OpenSim/Tests/Performance')
-rw-r--r--OpenSim/Tests/Performance/NPCPerformanceTests.cs190
-rw-r--r--OpenSim/Tests/Performance/ObjectPerformanceTests.cs175
-rw-r--r--OpenSim/Tests/Performance/ScriptPerformanceTests.cs168
3 files changed, 533 insertions, 0 deletions
diff --git a/OpenSim/Tests/Performance/NPCPerformanceTests.cs b/OpenSim/Tests/Performance/NPCPerformanceTests.cs
new file mode 100644
index 0000000..627765b
--- /dev/null
+++ b/OpenSim/Tests/Performance/NPCPerformanceTests.cs
@@ -0,0 +1,190 @@
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
28using System;
29using System.Collections.Generic;
30using System.Diagnostics;
31using System.Reflection;
32using log4net;
33using Nini.Config;
34using NUnit.Framework;
35using OpenMetaverse;
36using OpenSim.Framework;
37using OpenSim.Framework.Communications;
38using OpenSim.Region.CoreModules.Avatar.Attachments;
39using OpenSim.Region.CoreModules.Avatar.AvatarFactory;
40using OpenSim.Region.CoreModules.Framework.InventoryAccess;
41using OpenSim.Region.CoreModules.Framework.UserManagement;
42using OpenSim.Region.CoreModules.ServiceConnectorsOut.Avatar;
43using OpenSim.Region.Framework.Interfaces;
44using OpenSim.Region.Framework.Scenes;
45using OpenSim.Region.OptionalModules.World.NPC;
46using OpenSim.Services.AvatarService;
47using OpenSim.Tests.Common;
48using OpenSim.Tests.Common.Mock;
49
50namespace OpenSim.Tests.Performance
51{
52 /// <summary>
53 /// NPC performance tests
54 /// </summary>
55 /// <remarks>
56 /// Don't rely on the numbers given by these tests - they will vary a lot depending on what is already cached,
57 /// how much memory is free, etc. In some cases, later larger tests will apparently take less time than smaller
58 /// earlier tests.
59 /// </remarks>
60 [TestFixture]
61 public class NPCPerformanceTests
62 {
63 private TestScene scene;
64 private AvatarFactoryModule afm;
65 private UserManagementModule umm;
66 private AttachmentsModule am;
67
68 [TestFixtureSetUp]
69 public void FixtureInit()
70 {
71 // Don't allow tests to be bamboozled by asynchronous events. Execute everything on the same thread.
72 Util.FireAndForgetMethod = FireAndForgetMethod.None;
73 }
74
75 [TestFixtureTearDown]
76 public void TearDown()
77 {
78 scene.Close();
79 scene = null;
80 GC.Collect();
81 GC.WaitForPendingFinalizers();
82
83 // We must set this back afterwards, otherwise later tests will fail since they're expecting multiple
84 // threads. Possibly, later tests should be rewritten not to worry about such things.
85 Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod;
86 }
87
88 [SetUp]
89 public void Init()
90 {
91 IConfigSource config = new IniConfigSource();
92 config.AddConfig("NPC");
93 config.Configs["NPC"].Set("Enabled", "true");
94 config.AddConfig("Modules");
95 config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule");
96
97 afm = new AvatarFactoryModule();
98 umm = new UserManagementModule();
99 am = new AttachmentsModule();
100
101 scene = new SceneHelpers().SetupScene();
102 SceneHelpers.SetupSceneModules(scene, config, afm, umm, am, new BasicInventoryAccessModule(), new NPCModule());
103 }
104
105 [Test]
106 public void Test_0001_AddRemove100NPCs()
107 {
108 TestHelpers.InMethod();
109// log4net.Config.XmlConfigurator.Configure();
110
111 TestAddRemoveNPCs(100);
112 }
113
114 [Test]
115 public void Test_0002_AddRemove1000NPCs()
116 {
117 TestHelpers.InMethod();
118// log4net.Config.XmlConfigurator.Configure();
119
120 TestAddRemoveNPCs(1000);
121 }
122
123 [Test]
124 public void Test_0003_AddRemove2000NPCs()
125 {
126 TestHelpers.InMethod();
127// log4net.Config.XmlConfigurator.Configure();
128
129 TestAddRemoveNPCs(2000);
130 }
131
132 private void TestAddRemoveNPCs(int numberOfNpcs)
133 {
134 ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1));
135// ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId);
136
137 // 8 is the index of the first baked texture in AvatarAppearance
138 UUID originalFace8TextureId = TestHelpers.ParseTail(0x10);
139 Primitive.TextureEntry originalTe = new Primitive.TextureEntry(UUID.Zero);
140 Primitive.TextureEntryFace originalTef = originalTe.CreateFace(8);
141 originalTef.TextureID = originalFace8TextureId;
142
143 // We also need to add the texture to the asset service, otherwise the AvatarFactoryModule will tell
144 // ScenePresence.SendInitialData() to reset our entire appearance.
145 scene.AssetService.Store(AssetHelpers.CreateNotecardAsset(originalFace8TextureId));
146
147 afm.SetAppearance(sp, originalTe, null);
148
149 INPCModule npcModule = scene.RequestModuleInterface<INPCModule>();
150
151 List<UUID> npcs = new List<UUID>();
152
153 long startGcMemory = GC.GetTotalMemory(true);
154 Stopwatch sw = new Stopwatch();
155 sw.Start();
156
157 for (int i = 0; i < numberOfNpcs; i++)
158 {
159 npcs.Add(
160 npcModule.CreateNPC("John", "Smith", new Vector3(128, 128, 30), UUID.Zero, true, scene, sp.Appearance));
161 }
162
163 for (int i = 0; i < numberOfNpcs; i++)
164 {
165 Assert.That(npcs[i], Is.Not.Null);
166
167 ScenePresence npc = scene.GetScenePresence(npcs[i]);
168 Assert.That(npc, Is.Not.Null);
169 }
170
171 for (int i = 0; i < numberOfNpcs; i++)
172 {
173 Assert.That(npcModule.DeleteNPC(npcs[i], scene), Is.True);
174 ScenePresence npc = scene.GetScenePresence(npcs[i]);
175 Assert.That(npc, Is.Null);
176 }
177
178 sw.Stop();
179
180 long endGcMemory = GC.GetTotalMemory(true);
181
182 Console.WriteLine("Took {0} ms", sw.ElapsedMilliseconds);
183 Console.WriteLine(
184 "End {0} MB, Start {1} MB, Diff {2} MB",
185 endGcMemory / 1024 / 1024,
186 startGcMemory / 1024 / 1024,
187 (endGcMemory - startGcMemory) / 1024 / 1024);
188 }
189 }
190} \ No newline at end of file
diff --git a/OpenSim/Tests/Performance/ObjectPerformanceTests.cs b/OpenSim/Tests/Performance/ObjectPerformanceTests.cs
new file mode 100644
index 0000000..2264d86
--- /dev/null
+++ b/OpenSim/Tests/Performance/ObjectPerformanceTests.cs
@@ -0,0 +1,175 @@
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
28using System;
29using System.Diagnostics;
30using System.Reflection;
31using log4net;
32using NUnit.Framework;
33using OpenMetaverse;
34using OpenSim.Framework;
35using OpenSim.Region.Framework.Scenes;
36using OpenSim.Tests.Common;
37using OpenSim.Tests.Common.Mock;
38
39namespace 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
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} \ No newline at end of file
diff --git a/OpenSim/Tests/Performance/ScriptPerformanceTests.cs b/OpenSim/Tests/Performance/ScriptPerformanceTests.cs
new file mode 100644
index 0000000..d708abd
--- /dev/null
+++ b/OpenSim/Tests/Performance/ScriptPerformanceTests.cs
@@ -0,0 +1,168 @@
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
28using System;
29using System.Collections.Generic;
30using System.Diagnostics;
31using System.Reflection;
32using System.Threading;
33using log4net;
34using Nini.Config;
35using NUnit.Framework;
36using OpenMetaverse;
37using OpenSim.Framework;
38using OpenSim.Region.CoreModules.Scripting.WorldComm;
39using OpenSim.Region.Framework.Interfaces;
40using OpenSim.Region.Framework.Scenes;
41using OpenSim.Region.ScriptEngine.XEngine;
42using OpenSim.Tests.Common;
43using OpenSim.Tests.Common.Mock;
44
45namespace OpenSim.Tests.Performance
46{
47 /// <summary>
48 /// Script performance tests
49 /// </summary>
50 /// <remarks>
51 /// Don't rely on the numbers given by these tests - they will vary a lot depending on what is already cached,
52 /// how much memory is free, etc. In some cases, later larger tests will apparently take less time than smaller
53 /// earlier tests.
54 /// </remarks>
55 [TestFixture]
56 public class ScriptPerformanceTests
57 {
58 private TestScene m_scene;
59 private XEngine m_xEngine;
60 private AutoResetEvent m_chatEvent = new AutoResetEvent(false);
61
62 private int m_expectedChatMessages;
63 private List<OSChatMessage> m_osChatMessagesReceived = new List<OSChatMessage>();
64
65 [SetUp]
66 public void Init()
67 {
68 //AppDomain.CurrentDomain.SetData("APPBASE", Environment.CurrentDirectory + "/bin");
69// Console.WriteLine(AppDomain.CurrentDomain.BaseDirectory);
70 m_xEngine = new XEngine();
71
72 // Necessary to stop serialization complaining
73 WorldCommModule wcModule = new WorldCommModule();
74
75 IniConfigSource configSource = new IniConfigSource();
76
77 IConfig startupConfig = configSource.AddConfig("Startup");
78 startupConfig.Set("DefaultScriptEngine", "XEngine");
79
80 IConfig xEngineConfig = configSource.AddConfig("XEngine");
81 xEngineConfig.Set("Enabled", "true");
82
83 // These tests will not run with AppDomainLoading = true, at least on mono. For unknown reasons, the call
84 // to AssemblyResolver.OnAssemblyResolve fails.
85 xEngineConfig.Set("AppDomainLoading", "false");
86
87 m_scene = new SceneHelpers().SetupScene("My Test", UUID.Random(), 1000, 1000, configSource);
88 SceneHelpers.SetupSceneModules(m_scene, configSource, m_xEngine, wcModule);
89
90 m_scene.EventManager.OnChatFromWorld += OnChatFromWorld;
91 m_scene.StartScripts();
92 }
93
94 [TearDown]
95 public void TearDown()
96 {
97 m_scene.Close();
98 m_scene = null;
99 GC.Collect();
100 GC.WaitForPendingFinalizers();
101 }
102
103 [Test]
104 public void TestCompileAndStart100Scripts()
105 {
106 TestHelpers.InMethod();
107 log4net.Config.XmlConfigurator.Configure();
108
109 TestCompileAndStartScripts(100);
110 }
111
112 private void TestCompileAndStartScripts(int scriptsToCreate)
113 {
114 UUID userId = TestHelpers.ParseTail(0x1);
115
116 m_expectedChatMessages = scriptsToCreate;
117 int startingObjectIdTail = 0x100;
118
119 GC.Collect();
120
121 for (int idTail = startingObjectIdTail;idTail < startingObjectIdTail + scriptsToCreate; idTail++)
122 {
123 AddObjectAndScript(idTail, userId);
124 }
125
126 m_chatEvent.WaitOne(40000 + scriptsToCreate * 1000);
127
128 Assert.That(m_osChatMessagesReceived.Count, Is.EqualTo(m_expectedChatMessages));
129
130 foreach (OSChatMessage msg in m_osChatMessagesReceived)
131 Assert.That(
132 msg.Message,
133 Is.EqualTo("Script running"),
134 string.Format(
135 "Message from {0} was {1} rather than {2}", msg.SenderUUID, msg.Message, "Script running"));
136 }
137
138 private void AddObjectAndScript(int objectIdTail, UUID userId)
139 {
140// UUID itemId = TestHelpers.ParseTail(0x3);
141 string itemName = string.Format("AddObjectAndScript() Item for object {0}", objectIdTail);
142
143 SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId, "AddObjectAndScriptPart_", objectIdTail);
144 m_scene.AddNewSceneObject(so, true);
145
146 InventoryItemBase itemTemplate = new InventoryItemBase();
147// itemTemplate.ID = itemId;
148 itemTemplate.Name = itemName;
149 itemTemplate.Folder = so.UUID;
150 itemTemplate.InvType = (int)InventoryType.LSL;
151
152 m_scene.RezNewScript(userId, itemTemplate);
153 }
154
155 private void OnChatFromWorld(object sender, OSChatMessage oscm)
156 {
157// Console.WriteLine("Got chat [{0}]", oscm.Message);
158
159 lock (m_osChatMessagesReceived)
160 {
161 m_osChatMessagesReceived.Add(oscm);
162
163 if (m_osChatMessagesReceived.Count == m_expectedChatMessages)
164 m_chatEvent.Set();
165 }
166 }
167 }
168} \ No newline at end of file