perf measurements on ChangeMap, and World.ctor
This commit is contained in:
@@ -10,6 +10,7 @@ using OpenRa.Orders;
|
|||||||
using OpenRa.Support;
|
using OpenRa.Support;
|
||||||
using OpenRa.Traits;
|
using OpenRa.Traits;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
using Timer = OpenRa.Support.Timer;
|
||||||
|
|
||||||
namespace OpenRa
|
namespace OpenRa
|
||||||
{
|
{
|
||||||
@@ -35,7 +36,10 @@ namespace OpenRa
|
|||||||
|
|
||||||
public static void ChangeMap(string mapName)
|
public static void ChangeMap(string mapName)
|
||||||
{
|
{
|
||||||
|
Timer.Time( "----ChangeMap" );
|
||||||
|
|
||||||
var manifest = new Manifest(LobbyInfo.GlobalSettings.Mods);
|
var manifest = new Manifest(LobbyInfo.GlobalSettings.Mods);
|
||||||
|
Timer.Time( "manifest: {0}" );
|
||||||
|
|
||||||
chat.AddLine(Color.White, "Debug", "Map change {0} -> {1}".F(Game.mapName, mapName));
|
chat.AddLine(Color.White, "Debug", "Map change {0} -> {1}".F(Game.mapName, mapName));
|
||||||
Game.changePending = false;
|
Game.changePending = false;
|
||||||
@@ -43,11 +47,14 @@ namespace OpenRa
|
|||||||
SheetBuilder.Initialize(renderer);
|
SheetBuilder.Initialize(renderer);
|
||||||
SpriteSheetBuilder.Initialize();
|
SpriteSheetBuilder.Initialize();
|
||||||
FileSystem.UnmountTemporaryPackages();
|
FileSystem.UnmountTemporaryPackages();
|
||||||
|
Timer.Time( "reset: {0}" );
|
||||||
|
|
||||||
foreach (var pkg in manifest.Packages)
|
foreach (var pkg in manifest.Packages)
|
||||||
FileSystem.MountTemporary(new Package(pkg));
|
FileSystem.MountTemporary(new Package(pkg));
|
||||||
|
Timer.Time( "mount tempory packages: {0}" );
|
||||||
|
|
||||||
Rules.LoadRules(mapName, manifest);
|
Rules.LoadRules(mapName, manifest);
|
||||||
|
Timer.Time( "load rules: {0}" );
|
||||||
|
|
||||||
world = null; // trying to access the old world will NRE, rather than silently doing it wrong.
|
world = null; // trying to access the old world will NRE, rather than silently doing it wrong.
|
||||||
world = new World();
|
world = new World();
|
||||||
@@ -56,18 +63,25 @@ namespace OpenRa
|
|||||||
if (a.Owner != null && a.Info.Traits.Contains<OwnedActorInfo>())
|
if (a.Owner != null && a.Info.Traits.Contains<OwnedActorInfo>())
|
||||||
a.Owner.Shroud.Explore(a);
|
a.Owner.Shroud.Explore(a);
|
||||||
};
|
};
|
||||||
|
Timer.Time( "world: {0}" );
|
||||||
|
|
||||||
SequenceProvider.Initialize(manifest.Sequences);
|
SequenceProvider.Initialize(manifest.Sequences);
|
||||||
viewport = new Viewport(clientSize, Game.world.Map.Offset, Game.world.Map.Offset + Game.world.Map.Size, renderer);
|
viewport = new Viewport(clientSize, Game.world.Map.Offset, Game.world.Map.Offset + Game.world.Map.Size, renderer);
|
||||||
|
Timer.Time( "SeqProv, viewport: {0}" );
|
||||||
|
|
||||||
skipMakeAnims = true;
|
skipMakeAnims = true;
|
||||||
foreach (var treeReference in Game.world.Map.Trees)
|
foreach (var treeReference in Game.world.Map.Trees)
|
||||||
world.CreateActor(treeReference.Image, new int2(treeReference.Location), null);
|
world.CreateActor(treeReference.Image, new int2(treeReference.Location), null);
|
||||||
|
Timer.Time( "trees: {0}" );
|
||||||
|
|
||||||
world.LoadMapActors(Rules.AllRules);
|
world.LoadMapActors(Rules.AllRules);
|
||||||
skipMakeAnims = false;
|
skipMakeAnims = false;
|
||||||
|
Timer.Time( "map actors: {0}" );
|
||||||
|
|
||||||
chrome = new Chrome(renderer);
|
chrome = new Chrome(renderer);
|
||||||
|
Timer.Time( "chrome: {0}" );
|
||||||
|
|
||||||
|
Timer.Time( "----end ChangeMap" );
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static void Initialize(string mapName, Renderer renderer, int2 clientSize, int localPlayer, Controller controller)
|
internal static void Initialize(string mapName, Renderer renderer, int2 clientSize, int localPlayer, Controller controller)
|
||||||
|
|||||||
@@ -47,27 +47,38 @@ namespace OpenRa
|
|||||||
|
|
||||||
public World()
|
public World()
|
||||||
{
|
{
|
||||||
|
Timer.Time( "----World.ctor" );
|
||||||
|
|
||||||
Map = new Map( Rules.AllRules );
|
Map = new Map( Rules.AllRules );
|
||||||
|
Timer.Time( "new Map: {0}" );
|
||||||
FileSystem.MountTemporary( new Package( Map.Theater + ".mix" ) );
|
FileSystem.MountTemporary( new Package( Map.Theater + ".mix" ) );
|
||||||
|
Timer.Time( "mount temporary packages: {0}" );
|
||||||
TileSet = new TileSet( Map.TileSuffix );
|
TileSet = new TileSet( Map.TileSuffix );
|
||||||
|
Timer.Time( "Tileset: {0}" );
|
||||||
|
|
||||||
BuildingInfluence = new BuildingInfluenceMap( this );
|
BuildingInfluence = new BuildingInfluenceMap( this );
|
||||||
UnitInfluence = new UnitInfluenceMap( this );
|
UnitInfluence = new UnitInfluenceMap( this );
|
||||||
|
Timer.Time( "BIM/UIM: {0}" );
|
||||||
|
|
||||||
oreFrequency = (int)(Rules.General.GrowthRate * 60 * 25);
|
oreFrequency = (int)(Rules.General.GrowthRate * 60 * 25);
|
||||||
oreTicks = oreFrequency;
|
oreTicks = oreFrequency;
|
||||||
Map.InitOreDensity();
|
Map.InitOreDensity();
|
||||||
|
Timer.Time( "Ore: {0}" );
|
||||||
|
|
||||||
CreateActor("World", new int2(int.MaxValue, int.MaxValue), null);
|
CreateActor("World", new int2(int.MaxValue, int.MaxValue), null);
|
||||||
|
|
||||||
for (int i = 0; i < 8; i++)
|
for (int i = 0; i < 8; i++)
|
||||||
players[i] = new Player(this, i, Game.LobbyInfo.Clients.FirstOrDefault(a => a.Index == i));
|
players[i] = new Player(this, i, Game.LobbyInfo.Clients.FirstOrDefault(a => a.Index == i));
|
||||||
|
Timer.Time( "worldActor, players: {0}" );
|
||||||
|
|
||||||
Bridges.MakeBridges(this);
|
Bridges.MakeBridges(this);
|
||||||
PathFinder = new PathFinder(this);
|
PathFinder = new PathFinder(this);
|
||||||
|
Timer.Time( "bridge, pathing: {0}" );
|
||||||
|
|
||||||
WorldRenderer = new WorldRenderer(this, Game.renderer);
|
WorldRenderer = new WorldRenderer(this, Game.renderer);
|
||||||
Minimap = new Minimap(this, Game.renderer);
|
Minimap = new Minimap(this, Game.renderer);
|
||||||
|
Timer.Time( "renderer, minimap: {0}" );
|
||||||
|
Timer.Time( "----end World.ctor" );
|
||||||
}
|
}
|
||||||
|
|
||||||
public Actor CreateActor( string name, int2 location, Player owner )
|
public Actor CreateActor( string name, int2 location, Player owner )
|
||||||
|
|||||||
Reference in New Issue
Block a user