29 using System.Collections.Generic;
30 using System.Diagnostics;
31 using System.Reflection;
34 using NUnit.Framework;
36 using OpenSim.Framework;
38 using OpenSim.Region.CoreModules.Avatar.Attachments;
39 using OpenSim.Region.CoreModules.Avatar.AvatarFactory;
40 using OpenSim.Region.CoreModules.Framework.InventoryAccess;
41 using OpenSim.Region.CoreModules.Framework.UserManagement;
42 using OpenSim.Region.CoreModules.ServiceConnectorsOut.Avatar;
43 using OpenSim.Region.Framework.Interfaces;
44 using OpenSim.Region.Framework.Scenes;
45 using OpenSim.Region.OptionalModules.World.NPC;
46 using OpenSim.Services.AvatarService;
47 using OpenSim.Tests.Common;
71 Util.FireAndForgetMethod = FireAndForgetMethod.None;
80 GC.WaitForPendingFinalizers();
84 Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod;
90 IConfigSource config =
new IniConfigSource();
91 config.AddConfig(
"NPC");
92 config.Configs[
"NPC"].Set(
"Enabled",
"true");
93 config.AddConfig(
"Modules");
94 config.Configs[
"Modules"].Set(
"InventoryAccessModule",
"BasicInventoryAccessModule");
107 TestHelpers.InMethod();
110 TestAddRemoveNPCs(100);
116 TestHelpers.InMethod();
119 TestAddRemoveNPCs(1000);
125 TestHelpers.InMethod();
128 TestAddRemoveNPCs(2000);
131 private void TestAddRemoveNPCs(
int numberOfNpcs)
133 ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1));
137 UUID originalFace8TextureId = TestHelpers.ParseTail(0x10);
138 Primitive.TextureEntry originalTe =
new Primitive.TextureEntry(UUID.Zero);
139 Primitive.TextureEntryFace originalTef = originalTe.CreateFace(8);
140 originalTef.TextureID = originalFace8TextureId;
144 scene.AssetService.Store(AssetHelpers.CreateNotecardAsset(originalFace8TextureId));
150 List<UUID> npcs =
new List<UUID>();
152 long startGcMemory = GC.GetTotalMemory(
true);
153 Stopwatch sw =
new Stopwatch();
156 for (
int i = 0; i < numberOfNpcs; i++)
159 npcModule.CreateNPC(
"John",
"Smith",
new Vector3(128, 128, 30), UUID.Zero,
true, scene, sp.Appearance));
162 for (
int i = 0; i < numberOfNpcs; i++)
164 Assert.That(npcs[i], Is.Not.Null);
167 Assert.That(npc, Is.Not.Null);
170 for (
int i = 0; i < numberOfNpcs; i++)
172 Assert.That(npcModule.DeleteNPC(npcs[i], scene), Is.True);
174 Assert.That(npc, Is.Null);
179 long endGcMemory = GC.GetTotalMemory(
true);
181 Console.WriteLine(
"Took {0} ms", sw.ElapsedMilliseconds);
183 "End {0} MB, Start {1} MB, Diff {2} MB",
184 endGcMemory / 1024 / 1024,
185 startGcMemory / 1024 / 1024,
186 (endGcMemory - startGcMemory) / 1024 / 1024);
Helpers for setting up scenes.
Interactive OpenSim region server