-
Notifications
You must be signed in to change notification settings - Fork 105
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.
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.
- 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.
- Always Freeze() any freezable objects such as pens, brushes or paths. This can save a lot of performance.
- Try to minimize images usage or try to find optimum image size to display.
- 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.
- 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.