Skip to content

Commit

Permalink
removing a no-time-at-all timer; logging long-running trait Tick()
Browse files Browse the repository at this point in the history
  • Loading branch information
ytinasni committed Apr 11, 2010
1 parent fa56be7 commit 3271303
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
8 changes: 5 additions & 3 deletions OpenRA.Game/Graphics/Viewport.cs
Expand Up @@ -139,18 +139,20 @@ public void DrawRegions( World world )
lastConnectionState = state;

}
Timer.Time( "checking connections: {0}" );

Game.chrome.DrawWidgets(world);
Timer.Time( "widgets: {0}" );

var cursorName = Game.chrome.HitTest(mousePos) ? "default" : Game.controller.ChooseCursor( world );
var c = new Cursor(cursorName);
cursorRenderer.DrawSprite(c.GetSprite((int)cursorFrame), mousePos + Location - c.GetHotspot(), "cursor");
cursorRenderer.Flush();
Timer.Time( "cursors: {0}" );

renderer.RgbaSpriteRenderer.Flush();
renderer.SpriteRenderer.Flush();
renderer.WorldSpriteRenderer.Flush();

renderer.EndFrame();
Timer.Time( "endFrame: {0}" );
}

public void Tick()
Expand Down
12 changes: 11 additions & 1 deletion OpenRA.Game/World.cs
Expand Up @@ -144,8 +144,18 @@ public void Remove(Actor a)

public void Tick()
{
var sw = new Stopwatch();

foreach (var a in actors) a.Tick();
Queries.WithTraitMultiple<ITick>().Do( x => x.Trait.Tick( x.Actor ) );

Queries.WithTraitMultiple<ITick>().Do( x =>
{
var t = sw.ElapsedTime();
x.Trait.Tick( x.Actor );
var dt = sw.ElapsedTime() - t;
if( dt > 0.001 )
Log.Write( "expensive tick: {0}->{1}", x.Actor.Info.Name, x.Trait.GetType() );
} );

foreach (var e in effects) e.Tick( this );

Expand Down

0 comments on commit 3271303

Please sign in to comment.