[Gtk-sharp-list] gtk-dotnet performance

Jonathan Resnick jresnick at gmail.com
Tue Feb 28 22:07:29 EST 2006


I am trying to port an open-source medical imaging application from .NET to
Mono so that it can run on Linux. A large part of the codebase is based on
the System.Drawing library - therefore I am trying to use the gtk-dotnet
bridge so that GTK can be used as a front end. However, I'm having a hard
time getting decent performance, and as far as I can tell, the problems seem
to stem from the gtk-dotnet component.

I've attached a sample application that just tries to flip two
System.Drawing.Bitmaps to a Gtk.DrawingArea, alternating them, in a tight
loop. It measures the time taken for each flip and prints it to the console.

On Linux, I observe the following behaviour:

1. My first approach was to try drawing directly to the screen (_drawDirect
= true in the OnExposeEvent handler). The performance is good for roughly
the first 100 or so loop iterations, but then it quickly degrades. It seems
as though the system starts to run out of memory, which seems to be caused
by creating a Graphics object using Gtk.DotNet.Graphics.FromDrawable inside
the OnExposeEvent handler.

2. My second approach was to try drawing to an intermediate Pixmap
(_drawDirect = false in the OnExposeEvent handler), so as to avoid having to
create a Graphics object each time. In this case, the performance is
constant over the entire duration of the loop. However, the performance is
pretty bad, taking roughly 1 second per flip, which is not acceptable for
our purposes (and I'm running it on a reasonably powerful laptop machine).

If someone with a solid understanding of Gtk/Gdk could look at my sample
code and point out to me where I'm going wrong, it would be a huge help in
getting this application running on Linux.

Thanks,

Jonathan

-------------- next part --------------
A non-text attachment was scrubbed...
Name: sampleapp.zip
Type: application/octet-stream
Size: 19625 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/gtk-sharp-list/attachments/20060228/3146fc99/sampleapp-0001.obj


More information about the Gtk-sharp-list mailing list