gut perf logging - only record expensive ticks. perf.log is small enough to be useful now.

This commit is contained in:
Paul Chote
2010-09-06 15:29:34 +12:00
parent 06e8b530ea
commit 598fe9f956
4 changed files with 3 additions and 38 deletions

View File

@@ -49,9 +49,7 @@ namespace OpenRA
viewport = new Viewport(new float2(Renderer.Resolution), map.TopLeft, map.BottomRight, Renderer);
world = null; // trying to access the old world will NRE, rather than silently doing it wrong.
Timer.Time("viewport: {0}");
world = new World(modData.Manifest, map);
Timer.Time("world: {0}");
}
public static void MoveViewport(int2 loc)

View File

@@ -90,26 +90,20 @@ namespace OpenRA.Graphics
public void DrawRegions( World world )
{
Timer.Time( "DrawRegions start" );
renderer.BeginFrame(scrollPosition);
world.WorldRenderer.Draw();
Timer.Time( "worldRenderer: {0}" );
Widget.DoDraw(world);
Timer.Time( "widgets: {0}" );
var cursorName = Widget.RootWidget.GetCursorOuter(Viewport.LastMousePos) ?? "default";
var c = new Cursor(cursorName);
c.Draw((int)cursorFrame, Viewport.LastMousePos + Location);
Timer.Time( "cursors: {0}" );
renderer.RgbaSpriteRenderer.Flush();
renderer.SpriteRenderer.Flush();
renderer.WorldSpriteRenderer.Flush();
renderer.EndFrame();
Timer.Time( "endFrame: {0}" );
}
public void RefreshPalette()

View File

@@ -59,21 +59,15 @@ namespace OpenRA
if (!AvailableMaps.ContainsKey(uid))
throw new InvalidDataException("Invalid map uid: {0}".F(uid));
Timer.Time("----PrepareMap");
var map = new Map(AvailableMaps[uid].Package);
Timer.Time( "Map: {0}" );
Rules.LoadRules(Manifest, map);
Timer.Time( "Rules: {0}" );
if (map.Theater != cachedTheatre)
{
SpriteSheetBuilder.Initialize( Rules.TileSets[map.Tileset] );
SequenceProvider.Initialize(Manifest.Sequences);
Timer.Time("SSB, SeqProv: {0}");
cachedTheatre = map.Theater;
}
Timer.Time("----end PrepareMap");
return map;
}
}

View File

@@ -78,15 +78,12 @@ namespace OpenRA
public World(Manifest manifest, Map map)
{
Timer.Time( "----World.ctor" );
Map = map;
TileSet = Rules.TileSets[Map.Tileset];
TileSet.LoadTiles();
Timer.Time( "Tileset: {0}" );
WorldRenderer = new WorldRenderer(this);
Timer.Time("renderer: {0}");
WorldActor = CreateActor( "World", new TypeDictionary() );
Queries = new AllQueries(this);
@@ -101,16 +98,10 @@ namespace OpenRA
if (!p.Stances.ContainsKey(q))
p.Stances[q] = Stance.Neutral;
Timer.Time( "worldActor, players: {0}" );
PathFinder = new PathFinder(this);
foreach (var wlh in WorldActor.TraitsImplementing<IWorldLoaded>())
wlh.WorldLoaded(this);
Timer.Time( "hooks, pathing: {0}" );
Timer.Time( "----end World.ctor" );
}
public Actor CreateActor( string name, TypeDictionary initDict )
@@ -155,31 +146,19 @@ namespace OpenRA
if (DisableTick)
return;
Timer.Time("----World Tick");
actors.DoTimed( x => x.Tick(), "expensive actor tick: {0} ({1:0.000})", 0.001 );
Timer.Time(" actors: {0:0.000}");
actors.DoTimed( x => x.Tick(), "expensive actor tick: {0} ({1:0.000} ms)", 0.001 );
Queries.WithTraitMultiple<ITick>().DoTimed( x =>
{
x.Trait.Tick( x.Actor );
Timer.Time( "trait tick \"{0}\": {{0}}".F( x.Trait.GetType().Name ) );
}, "expensive trait tick: {0} ({1:0.000})", 0.001 );
Timer.Time(" traits: {0:0.000}");
effects.DoTimed( e => e.Tick( this ), "expensive effect tick: {0} ({1:0.000})", 0.001 );
Timer.Time(" effects: {0:0.000}");
}, "expensive trait tick: {0} ({1:0.000} ms)", 0.001 );
effects.DoTimed( e => e.Tick( this ), "expensive effect tick: {0} ({1:0.000} ms)", 0.001 );
Game.viewport.Tick();
Timer.Time(" viewport: {0:0.000}");
while (frameEndActions.Count != 0)
frameEndActions.Dequeue()(this);
Timer.Time(" frameEndActions: {0:0.000}");
WorldRenderer.Tick();
Timer.Time(" worldrenderer: {0:0.000}");
}
public IEnumerable<Actor> Actors { get { return actors; } }