Measuring Draw Calls
Introduction
Rendering
Code Example: Checking Performance
protected override void Initialize()
{
// Initialize Gum - can load a project, although it isn't used below
GumUI.Initialize(this);
// Create a panel to hold all children.
var panel = new StackPanel();
panel.AddToRoot();
for(int i = 0; i < 5; i++)
{
var subContainer = new ContainerRuntime();
// ClipsChildren sets
subContainer.ClipsChildren = true;
panel.AddChild(subContainer);
var rectangle = new ColoredRectangleRuntime();
subContainer.AddChild(rectangle);
}
}
protected override void Update(GameTime gameTime)
{
GumUI.Update(gameTime);
base.Update(gameTime);
}
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.CornflowerBlue);
GumUI.Draw();
if(GumUI.Keyboard.KeyPushed(Keys.Space))
{
var spriteRenderer = GumUI.SystemManagers.Renderer.SpriteRenderer;
var lastFrameDrawStates = spriteRenderer.LastFrameDrawStates;
System.Diagnostics.Debug.WriteLine(
$"Last Frame Draw States ({lastFrameDrawStates.Count()}):");
foreach(var item in lastFrameDrawStates)
{
System.Diagnostics.Debug.WriteLine(item);
}
}
base.Draw(gameTime);
}
Last updated
Was this helpful?

