DrawingPerformanceTests ClassDelta Engine Documentation
Checks if raw performance of rendering lines and sprites is good. Fast GPU recommended. Please note that the test here simulate how the rendering classes work, you can get worse values if you draw many small batches and cause overhead the Rendering namespace optimizes already. View code on GitHub
Inheritance Hierarchy

System Object
  DeltaEngine.Platforms TestWithMocksOrVisually
    DeltaEngine.Graphics.Tests DrawingPerformanceTests

Namespace: DeltaEngine.Graphics.Tests
Assembly: DeltaEngine.Graphics.Tests (in DeltaEngine.Graphics.Tests.dll) Version: 1.1.1.0 (1.1.1)
Syntax

public class DrawingPerformanceTests : TestWithMocksOrVisually

The DrawingPerformanceTests type exposes the following members.

Constructors

  NameDescription
Public methodDrawingPerformanceTests
Initializes a new instance of the DrawingPerformanceTests class
Top
Methods

  NameDescription
Protected methodAdvanceTimeAndUpdateEntities (Inherited from TestWithMocksOrVisually.)
Public methodDraw30000LinesPerFrame
Proof that 30k lines can be rendered with up to 3000fps in a small window, fast GPU. Even 1000fps means that 30 million lines are drawn each second. More than 30k lines are possible with multiple draw calls, but causes multiple CircularBuffer flushes and thus not faster. View code on GitHub
Public methodDrawImagesWithOneMillionPolygonsPerFrame
Draws 100*100 small images (=10000 images =20000 polygons) 50 times a frame to reach 1 million polygons drawn per frame. Can reach 100fps or more, which means 100 million polygons per second. View code on GitHub
Public methodInitializeResolver (Inherited from TestWithMocksOrVisually.)
Protected methodRegisterMock T  (Inherited from TestWithMocksOrVisually.)
Protected methodResolve T  (Inherited from TestWithMocksOrVisually.)
Protected methodRunAfterFirstFrame (Inherited from TestWithMocksOrVisually.)
Public methodRunTestAndDisposeResolverWhenDone (Inherited from TestWithMocksOrVisually.)
Top
Properties

  NameDescription
Protected propertyIsMockResolver (Inherited from TestWithMocksOrVisually.)
Top
Examples

/// <summary> 
/// Proof that 30k lines can be rendered with up to 3000fps in a small window, fast GPU. Even 
/// 1000fps means that 30 million lines are drawn each second. More than 30k lines are possible 
/// with multiple draw calls, but causes multiple CircularBuffer flushes and thus not faster. 
/// </summary>
[Test, Category("Slow")]
public void Draw30000LinesPerFrame()
{
    var manyLines = new DrawingTests.Line(Vector2D.Zero, new Vector2D(1280, 720), Color.Red);
    const int NumberOfRandomLines = 30000;
    var vertices = new VertexPosition2DColor[2 * NumberOfRandomLines];
    var random = Randomizer.Current;
    var viewport = Resolve<Window>().ViewportPixelSize;
    for (int i = 0; i < NumberOfRandomLines; i++)
    {
        var startPoint = new Vector2D(random.Get(0, viewport.Width), random.Get(0, viewport.Height));
        var endPoint = startPoint + new Vector2D(random.Get(-50, 50), random.Get(-50, 50));
        vertices[i * 2 + 0] = new VertexPosition2DColor(startPoint, Color.GetRandomColor());
        vertices[i * 2 + 1] = new VertexPosition2DColor(endPoint, Color.GetRandomColor());
    }
    manyLines.Set(vertices);
}
/// <summary> 
/// Draws 100*100 small images (=10000 images =20000 polygons) 50 times a frame to reach 1 million 
/// polygons drawn per frame. Can reach 100fps or more, which means 100 million polygons per second. 
/// </summary>
[Test, Category("Slow")]
public void DrawImagesWithOneMillionPolygonsPerFrame()
{
    var verticesAndIndices = CreateVerticesAndIndices();
    verticesAndIndices.OnDraw<RenderOneMillionPolygons>();
}
See Also