Page 1 of 2

Debug output is terribly slow

Posted: Tue Jan 24, 2012 5:42 pm
by uwekel
Hi,

if you try the following code, it takes almost a minute to complete:

Code: Select all

For i = 1 To 10000
  Debug i
Next
The same code in python on the same machine takes less a second:

Code: Select all

for i in range(10000):
  print i
Just to let you know, that there is potential :-)

Best regards
Uwe

Re: Debug output is terribly slow

Posted: Tue Jan 24, 2012 6:58 pm
by Demivec
uwekel wrote:if you try the following code, it takes almost a minute to complete:

Code: Select all

For i = 1 To 10000
  Debug i
Next
The same code in python on the same machine takes less a second:

Code: Select all

for i in range(10000):
  print i
Just to let you know, that there is potential :-)
Is that code in python for debugging? For comparison use similar (non-debug) code in PureBasic and it will also run in less than a second:

Code: Select all

OpenConsole()
For i = 1 To 10000
  PrintN(Str(i))
Next
Input()

Re: Debug output is terribly slow

Posted: Tue Jan 24, 2012 8:10 pm
by uwekel
Yes, in Python the debugger is enabled (i just pressed F5 in Wing IDE).

What you can notice is that PB gets slower with every line of debug output. Maybe the output line will not actually appends to the list, but replaces the whole output text, e.g. something like

Code: Select all

Debug$ = Debug$ + #LF$ + Line$
... but that's just a guess.

Re: Debug output is terribly slow

Posted: Tue Jan 24, 2012 8:30 pm
by freak
The debug output is a convenience method for debugging. Its not intended for high-speed output. The console library is better suited for that.

Re: Debug output is terribly slow

Posted: Tue Jan 24, 2012 8:33 pm
by ts-soft
I think your problem have to do with this: http://www.purebasic.fr/english/viewtop ... 46#p370646

Greetings - Thomas

Re: Debug output is terribly slow

Posted: Wed Jan 25, 2012 1:01 pm
by Trond
It takes less than 15 seconds here. But GTK is a horribly slow toolkit so I guess the Linux version would use much longer time.

Re: Debug output is terribly slow

Posted: Wed Jan 25, 2012 1:17 pm
by remi_meier
Trond wrote:It takes less than 15 seconds here. But GTK is a horribly slow toolkit so I guess the Linux version would use much longer time.
3 seconds here :wink:

@uwekel: Besides debug not being the fastest, in what
circumstances do you want your debug-window filled so fast
that you are unable to read it? :P
Logging to a file seems to be the better solution in those cases.

Btw, it does not slow down here with every line of debug output.

Re: Debug output is terribly slow

Posted: Wed Jan 25, 2012 8:58 pm
by uwekel
I often use the Debug command to print some values to the output window. In my special case i received a bunch of lines from a newsserver. There was no need to read every line because it contained encoded data, but i just wanted to see the receiving result of an NNTP command.

I know the slowness is not dramatic and i just wanted to drop a note.
But GTK is a horribly slow toolkit so I guess the Linux version would use much longer time.
I don't think that we can blame it on GTK. The Wing IDE use GTK as well :-)
Btw, it does not slow down here with every line of debug output.
Maybe it is a Linux problem.

Best regards
Uwe

Re: Debug output is terribly slow

Posted: Wed Jan 25, 2012 9:32 pm
by remi_meier
uwekel wrote:[..]
But GTK is a horribly slow toolkit so I guess the Linux version would use much longer time.
I don't think that we can blame it on GTK. The Wing IDE use GTK as well :-)
Btw, it does not slow down here with every line of debug output.
Maybe it is a Linux problem.
Oh, I didn't mention that I was also using GTK on Linux.
But you were right, changing from 10'000 to 100'000
shows the slowdown here too.
I often use the Debug command to print some values to the output window. In my special case i received a bunch of lines from a newsserver. There was no need to read every line because it contained encoded data, but i just wanted to see the receiving result of an NNTP command.
Well I understand. Sometimes I also just want to see
what is currently going on. In that case it would
be useful if the debug-window had a buffer limit and
would just show the last 100 lines or so. Then again
I was often cursing Eclipse because it didn't keep enough
lines in the output window :P And as others were
suggesting, with an open terminal window you actually
get exactly this behaviour.

Re: Debug output is terribly slow

Posted: Thu Jan 26, 2012 10:02 am
by Trond
uwekel wrote:
But GTK is a horribly slow toolkit so I guess the Linux version would use much longer time.
I don't think that we can blame it on GTK. The Wing IDE use GTK as well :-)
The python console in Wing is actually a scintilla widget. You can tell by the prolonged horizontal scrollbar and the context menu that appears a few pixels off (and also Wing IDE is listed as using scintilla on scintilla.org).

Re: Debug output is terribly slow

Posted: Thu Jan 26, 2012 10:03 am
by Trond
I don't know if freak is still reading, but the performance could very likely be improved manifold simply by setting the all-rows-equal-height or similar sounding gtk property on the list.

Re: Debug output is terribly slow

Posted: Thu Jan 26, 2012 9:47 pm
by uwekel
But you were right, changing from 10'000 to 100'000 shows the slowdown here too.
That surprises me. I have an Intel i7-2600K with 8GB ram but no graphic card (i use the onboard intel graphics). Why the hell it is so slow?

Re: Debug output is terribly slow

Posted: Thu Jan 26, 2012 10:21 pm
by remi_meier
Interesting, I'm on Ubuntu 11.10 x64 with an Intel M620@2.67
with 8GB RAM and using the Intel onboard graphics card :)
Running PB on the Optimus powered Nvidia GT218 [NVS 3100M]
does not change anything.

Well, maybe you should try compiz as the window compositor
like used in Unity or XFCE. GnomeShell for example has still
some performance problems with some workloads.

Re: Debug output is terribly slow

Posted: Thu Jan 26, 2012 11:05 pm
by MachineCode
uwekel wrote:Why the hell it is so slow?
Because it's a debug output, not a runtime output (as Freak said). It's just meant to be used to display something to you to aid in debugging. Using it in a tight for/next loop like that is not debugging. You're trying to force it to be a pseudo-window instead of its intended purpose. "Debug" in PureBasic is not the same thing as "Print" in Python.

Re: Debug output is terribly slow

Posted: Mon Jan 30, 2012 11:44 pm
by void
Is Purebasic by any chance doing something like copying the entire current debug window data to a new structure every time text is added? Because my experience with the debug window (on Windows) does seem to result in it getting significantly slower to add data to it the more elements are in it.