[Gambas-user] strange thing! or not?

Benoit Minisini gambas at ...1...
Sun Aug 27 12:54:49 CEST 2006


On Sunday 27 August 2006 12:17, Benoit Minisini wrote:
> On Saturday 26 August 2006 23:46, Stefano Palmeri wrote:
> > Hi, all. Hi, Benoit.
> >
> > Working on a project that has some "SHELL ... TO", I noticed
> > that after compiling it slows down.
> >
> > I did some tests and found this strange thing: the same
> > code runs 4-5 times faster if it is in a console project
> > than in a QT project, after compiling of course.
> > My stupid question is: is it normal?
> >
> > I tested on a 900MHz machine, so on a faster computer
> > you may need to increase the loops in the code to notice the difference.
> >
> > I've attached the two test examples that give me so different timing
> > result after compiling.
> > Please, compile them and run both from a console.
> >
> > Gambas2 version is 1.9.39.
> >
> > Regards,
> >
> > Stefano Palmeri
>
> I changed your examples to loop 1000 times instead of 100, and I redirected
> the output to /dev/null so that the time to write to the terminal is the
> same in the two cases.
>
> I get these results:
>
> console: ~ 7.6 s
> QT:      ~ 9.3 s
>
> So it is very strange!
>
> Because if you use SHELL ... TO, then the event loop is not called, i.e. no
> specific QT code is execute. Theoretically, the same code is run in the two
> cases!
>
> More investigation is needed there...
>
> Regards,

Maybe I have an explanation.

When a QT program runs, it connects to the X11 server by creating a socket. By 
using 'strace', I noticed that something (the X11 library I think) sets the 
flag "close on exec" on this socket. 

So that means that each time you run an external program (by using SHELL or 
EXEC), this socket is closed. Maybe this could explain the slowness? Actually 
I don't know.

Regards,

-- 
Benoit Minisini





More information about the User mailing list