From 598fe9f9566c29659ec1a055409cc510fafadb7a Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Mon, 6 Sep 2010 15:29:34 +1200 Subject: [PATCH] gut perf logging - only record expensive ticks. perf.log is small enough to be useful now. --- OpenRA.Game/Game.cs | 2 -- OpenRA.Game/Graphics/Viewport.cs | 6 ------ OpenRA.Game/ModData.cs | 6 ------ OpenRA.Game/World.cs | 27 +++------------------------ 4 files changed, 3 insertions(+), 38 deletions(-) diff --git a/OpenRA.Game/Game.cs b/OpenRA.Game/Game.cs index d9c7d9767b..5bf30fe66a 100644 --- a/OpenRA.Game/Game.cs +++ b/OpenRA.Game/Game.cs @@ -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) diff --git a/OpenRA.Game/Graphics/Viewport.cs b/OpenRA.Game/Graphics/Viewport.cs index f796f5b427..c3b0a313d1 100644 --- a/OpenRA.Game/Graphics/Viewport.cs +++ b/OpenRA.Game/Graphics/Viewport.cs @@ -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() diff --git a/OpenRA.Game/ModData.cs b/OpenRA.Game/ModData.cs index 54b18f2a4f..4282360fa2 100755 --- a/OpenRA.Game/ModData.cs +++ b/OpenRA.Game/ModData.cs @@ -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; } } diff --git a/OpenRA.Game/World.cs b/OpenRA.Game/World.cs index 38740b1c6e..2e89ee1dae 100644 --- a/OpenRA.Game/World.cs +++ b/OpenRA.Game/World.cs @@ -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()) 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().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 Actors { get { return actors; } }