Recent

Author Topic: Qt beats GTK2  (Read 5391 times)

Fred vS

  • Hero Member
  • *****
  • Posts: 3168
    • StrumPract is the musicians best friend
Qt beats GTK2
« on: April 12, 2012, 07:55:48 pm »
Hello Lazarus fans.

Im impressed by the difference of speed between GTK2 and Qt.

Here a simple example to demonstrate it.
It use 3 images (one empty and 2 loaded in project) and a timer.
The timer is set to 300 ms.
The goal is to load alternatively image2.picture or image3.picture into image1.picture with timer1.
In the project i choose 2 images (for image2 and image3) of 3 megas octets in jpg format. 
Try to compile it with GTK2 (default) and then with Qt (go in Project/Project Options/Compiler Options and choose lcl Qt).

Code: [Select]
unit GTK2vsQt;

{$mode objfpc}{$H+}

interface

uses
   Classes, SysUtils, Forms,  Graphics, ExtCtrls,
  StdCtrls;
 
type

  { TForm1 }

  TForm1 = class(TForm)
    Button1: TButton;
    Image1: TImage;
    Image2: TImage;
    Image3: TImage;
    Timer1: TTimer;
    procedure FormCreate(Sender: TObject);     
    procedure Button1Click(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
  private
    { private declarations }
  public
    { public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.lfm}

{ TForm1 }
procedure TForm1.FormCreate(Sender: TObject);
begin
{$if defined(lclqt)}
  form1.Caption:=  'Qt slide test'  ;

  {$else}
   form1.Caption:=  'GTK2 slide test'  ;
     {$ENDIF}   
end;


procedure TForm1.Timer1Timer(Sender: TObject);
begin
  timer1.Enabled:=false;
   if image1.Tag = 0 then begin
    image1.Picture := image2.Picture;
    image1.Tag:= 1;
  end else  begin
    image1.Picture := image3.Picture;
    image1.Tag:= 0;
  end;
   timer1.Enabled:=true;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
   timer1.enabled := true;
end;

end.
                     

If you compare the result with GTK2 and QT, it takes 3 seconds to load images with GTK2 and... 0,3 second with Qt.

After that test i have some questions.

- Why GTK2 is loaded by default in each Linux version i have tested (Ubuntu, Mint,...).

- Does anybody know how to easy install in a GTK2 Linux system the Qt libraries needed for a Qt-Lazarus compiled program ?

Many thanks.
« Last Edit: April 12, 2012, 08:02:16 pm by Fred vS »
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: Qt beats GTK2
« Reply #1 on: April 12, 2012, 07:58:21 pm »
- Why GTK2 is loaded by default in each Linux version i have tested (Ubuntu, Mint,...).
Sorry, this just made my day.  :D

I'd think you'd have to ask the person who chose the Linux distro to be tested...

<Grins, Ducks & Runs>

Regards,
Bigchimp
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

zeljko

  • Hero Member
  • *****
  • Posts: 1596
    • http://wiki.lazarus.freepascal.org/User:Zeljan
Re: Qt beats GTK2
« Reply #2 on: April 12, 2012, 08:33:18 pm »
Hello Lazarus fans.

Im impressed by the difference of speed between GTK2 and Qt.

.... ...
- Why GTK2 is loaded by default in each Linux version i have tested (Ubuntu, Mint,...).

- Does anybody know how to easy install in a GTK2 Linux system the Qt libraries needed for a Qt-Lazarus compiled program ?

Many thanks.

Such diff is just because most distros packs Qt with raster graphicssystem as default. When Qt runs with native graphicssystem (x11) then it should be slower.
Try to start your app with ./myproject -graphicssystem native  and measure.
Any distro have qt packages, you just need to install it ...eg. rpm distros mostly uses yum , deb uses apt-get ...you need to familiarize with your distro.
http://wiki.lazarus.freepascal.org/index.php/Qt_Interface
http://users.telenet.be/Jan.Van.hijfte/qtforfpc/fpcqt4.html



AmatCoder

  • Jr. Member
  • **
  • Posts: 57
    • My site
Re: Qt beats GTK2
« Reply #3 on: April 12, 2012, 11:06:41 pm »
Im impressed by the difference of speed between GTK2 and Qt.
[...]
If you compare the result with GTK2 and QT, it takes 3 seconds to load images with GTK2 and... 0,3 second with Qt.

Although Qt can be faster than GTK2 in some areas, that difference is due to a malfunctioning in Lazarus LCL, for sure... I found this:
http://www.lazarus.freepascal.org/index.php/topic,15223.msg86658.html#msg86658

So correct assertion would be: :"I'm impressed by the difference of speed between LCL-GTK2 and LCL-Qt."

Quote
- Why GTK2 is loaded by default in each Linux version i have tested (Ubuntu, Mint,...).

If GTK2 were ten times slower than Qt then all distros would use Qt framework, I can assure you... ;) 

Regards.

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3538
Re: Qt beats GTK2
« Reply #4 on: April 12, 2012, 11:26:15 pm »
It would be interresting if you could compare against LCL-CustomDrawn too.

 

TinyPortal © 2005-2018