Skip to content

Performance VS Quality

Alexander Smirnov edited this page Jul 13, 2016 · 1 revision

< Back to contents >

  Last checked against version: 2.1.8
 

Some times performance matters. GraphX have some common logical enchancements that works toward the performance improvement but sometimes that is not enough. In this article i'll show you some custom ways to improve performance a little bit more.

 

Introduction into rendering performance

You can find a lot of articles over the internet about WPF overall performance and tips. So i'll say the basics.: the simplier object you want to draw - the more performant your App overall. I've tried to find the golden middle between the performance and features so i've used Panel (same as Canvas in terms of performance) as layout area and Control as drawed object. 
When you work with hundreds of objects it realy matters how you design templates or handle events (especialy WPF bubble events). That is why so important to performance-affected features optional.

Rendering performance tips

  1. You can significantly optimize rendering speed by using GraphArea::CacheMode property correctly. Generaly it can be setup to render all GraphArea objects in one pass into bitmap image that will be rendered on screen. This approach is effective for dense graphs with many edges as Bitmap is limited by 2048x2048 texture size. Also in this case the rendering quality suffers when using large zoom as bitmap isn't vector and will became pixelated. You must play with the settings and see if this approach satisfies your needs. 
    <pre class="brush:c#">
    

    CacheMode = new BitmapCache(2) { EnableClearType = false, SnapsToDevicePixels = true };  where 2 is objects scale ratio, bigger the value better the zoom quality but image size is also bigger so overal graph size possibly be smaller.

Custom events control

EdgeControl and VertexControl have property called EventOptions. Using this property you can configure which most usable events are listened or not. If you don't use any of them you can disable them to save a bit performance.

Custom visual templates

When using custom visual templates you should always hold in your mind how many vertices you want to draw. More complex the visual templates - more laggy graph will be. If you are oriented on the large vertices quantity (500+ i suppose) it is recommended to choose your templates wisely:
  1. Always Freeze() any freezable objects such as pens, brushes or paths. This can save a lot of performance.
  2. Try to minimize images usage or try to find optimum image size to display.
  3. Try to minimize bindings and especialy converters usage. Converters can seriously blow the performance if they are used to create objects such as pens or brushes.

Other custom features

  1. GraphArea.GenerateGraph(_dataGraph, true, true) method introduces automatic unique ID assignment for vertex and edge data objects that misses it. If you assign IDs manually you can switch this feature off using method param. This can save graph generation performance depending on graph size.