* * *

Author Topic: Why is gtk2 10 times slower than qt?  (Read 9879 times)

jarto

  • Full Member
  • ***
  • Posts: 106
Why is gtk2 10 times slower than qt?
« on: November 13, 2011, 11:22:24 am »
I created a small program to test how well the DirectDraw components perform. However, it became a test case for gtk2. The gtk2-version of the test case is over 10 times slower, than qt. That's a lot.

The test creates a lot of TButtons and TEdits and moves them around with a timer. After every move, the time is written to the form caption. Here are the results on my laptop:

qt: About 0.5 seconds
gtk2: About 7 seconds!  :o
win32 binary with wine: About 1 second.

qt with DirectDraw components: About 1.1 seconds
gtk2 with DirectDraw components: A bit under 7 seconds.
win32 binary with wine: About 1 second.

http://www.starsoft.fi/jarto/DirectDrawTest.zip contains source code and compiled binaries for gtk2 and qt.

Usage:
- Start the program
- Toggle Tools/Use DirectDraw components to switch between native controls and DirectDraw.
- Select Tools/Start

I'd be interested to know if other people have similar performance problems with gtk2.

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3537
Re: Why is gtk2 10 times slower than qt?
« Reply #1 on: November 13, 2011, 01:23:59 pm »
Well, in my oppinion the entire Gtk sucks. So it being slower, harder to use, inconsistent, buggy and whatever else is no surprise for me. Qt on the other hand is a very good and well written library.

Leledumbo

  • Hero Member
  • *****
  • Posts: 7628
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Why is gtk2 10 times slower than qt?
« Reply #2 on: November 13, 2011, 01:48:58 pm »
AFAIK GTK was never meant to be used as a general purpose GUI framework (at least in its first version), but GUI library for GIMP, which doesn't need a lot of speed at interface level. It was then separated from GIMP because the components seem quite usable for general use (but it ends up in a slow solution).

jarto

  • Full Member
  • ***
  • Posts: 106
Re: Why is gtk2 10 times slower than qt?
« Reply #3 on: November 13, 2011, 07:20:05 pm »
Do you guys get about the same performance with the test I wrote? I'd like to know if these numbers are normal for Lazarus & GTK2 or if there's something wrong with my setup.

Blaazen

  • Hero Member
  • *****
  • Posts: 2377
  • POKE 54296,15
    • Eye-Candy Controls
Re: Why is gtk2 10 times slower than qt?
« Reply #4 on: November 13, 2011, 07:56:12 pm »
I now tested on Chakra Linux 64-bit, KDE4, ATI Mobility RadeOn 4670HD, Catalyst 11.6
Lazarus SVN r. 33460,

Qt4: ~0:4
Qt4 + DirectDraw Components: ~0.5 (yes, it is a little slower)

GTK2: ~2:8
GTK2 + DirectDraw Components: ~1:8
Lazarus 1.9.0 r55618 FPC 3.0.2 x86_64-linux-qt Chakra, Qt 4.8.7, Plasma 5.9.4
Lazarus 1.6.4 r54278 FPC 3.0.2 i386-win32-win32/win64 Wine 2.4










Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

Troodon

  • Sr. Member
  • ****
  • Posts: 484
Re: Why is gtk2 10 times slower than qt?
« Reply #5 on: November 13, 2011, 08:08:45 pm »
I started a similar discussion related to GUI performance back in 2008. GTK2 performance was poor, at least when compared to Qt4 and Win32. However, by far the bottleneck statement in my code was Application.Processmessages. Upon removing it performance was comparable with all widgetsets tested. The bottom line is, consider updating the GUI as seldom as possible.
« Last Edit: November 13, 2011, 08:10:49 pm by Troodon »
Lazarus/FPC on Linux

Andru

  • Full Member
  • ***
  • Posts: 112
    • Homepage
Re: Why is gtk2 10 times slower than qt?
« Reply #6 on: November 13, 2011, 08:40:01 pm »
That is because of overhead inside LCL and other reasons... But, on my machine I get ~01:000 for Qt and ~01:600 for GTK2.

Quote from: felipemdc
Well, in my oppinion the entire Gtk sucks. So it being slower, harder to use, inconsistent, buggy and whatever else is no surprise for me. Qt on the other hand is a very good and well written library.
I lol'd so hard... :}

TurboRascal

  • Hero Member
  • *****
  • Posts: 672
  • "Good sysadmin. Bad programmer."™
Re: Why is gtk2 10 times slower than qt?
« Reply #7 on: November 14, 2011, 05:51:09 pm »
If I may ask, why GTK performance with DD matters at all? GTK is a cross-platform widgetset, yet DD is windows-only, so I'd say it would be natural for it to be used in conjunction with the WinAPI native widgets only, and LCL component wrap around all the above mentioned widgetsets... Unless you access GTK API directly though, which you probably don't since you say you tried with all three ones.
Regards, ArNy the Turbo Rascal
-
"The secret is to give them what they need, not what they want." - Scotty, STTNG:Relics

jarto

  • Full Member
  • ***
  • Posts: 106
Re: Why is gtk2 10 times slower than qt?
« Reply #8 on: November 15, 2011, 05:32:44 pm »
Thank you for your measurements. Looks like GTK2 is not as slow on good, modern hardware, but there's a big speed difference anyway. I did some more tests on my laptop at work, which is a lot faster. As that one also has Windows and Delphi, I was able to compare the speed to Lazarus/win32:

GTK2 on Linux: 2.9 seconds
Win32 on Windows XP: 0.6 seconds
Delphi 2007: 0.7 seconds

So Lazarus/win32 is actually faster, than Delphi, but some serious work needs to be done to improve GTK2.


JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3031
  • I like bugs.
Re: Why is gtk2 10 times slower than qt?
« Reply #9 on: November 15, 2011, 11:05:38 pm »
I didn't see even that big difference, GTK2 was max 2 times slower.
I didn't know if I should turn this DirectDraw thing on when comparing GTK2 and QT.

In practice I don't see any noticeable speed difference in a big application like Lazarus, when compiled for different widgetsets. GTK2 has other problems though.

Juha

zeljko

  • Hero Member
  • *****
  • Posts: 915
    • http://wiki.lazarus.freepascal.org/User:Zeljan
Re: Why is gtk2 10 times slower than qt?
« Reply #10 on: February 13, 2012, 05:46:42 pm »
Gtk2 is slower because of extra events processing and hardcoded num iterations (100) in Gtk2Widgetset. All of that is copied from gtk1 and never rewritten, except that I changed the way how glib2 main context is used.

mica

  • Full Member
  • ***
  • Posts: 181
Re: Why is gtk2 10 times slower than qt?
« Reply #11 on: February 13, 2012, 06:16:50 pm »
GTK2 1,933
Qt 0.27

ouch

Leledumbo

  • Hero Member
  • *****
  • Posts: 7628
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Why is gtk2 10 times slower than qt?
« Reply #12 on: February 14, 2012, 03:55:59 am »
after I change my Lazarus interface from gtk2 to qt, I never look back. I don't (need to) measure with any timer, just try comparing the speed of scrolling in the source editor.

mica

  • Full Member
  • ***
  • Posts: 181
Re: Why is gtk2 10 times slower than qt?
« Reply #13 on: March 27, 2017, 12:49:47 am »
for LuizAmérico

sources without binarys

LuizAmérico

  • Sr. Member
  • ****
  • Posts: 455
Re: Why is gtk2 10 times slower than qt?
« Reply #14 on: March 27, 2017, 01:39:27 am »
Thanks

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus