Debug output is terribly slow

Working on new editor enhancements?
uwekel
Enthusiast
Enthusiast
Posts: 740
Joined: Sat Dec 03, 2011 5:54 pm
Location: Oldenburg (Germany)

Debug output is terribly slow

Post 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
PB 5.70 LTS (x64) - Debian Testing, Gnome 3.30.2
User avatar
Demivec
Addict
Addict
Posts: 4269
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Re: Debug output is terribly slow

Post 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()
Last edited by Demivec on Tue Jan 24, 2012 9:13 pm, edited 1 time in total.
uwekel
Enthusiast
Enthusiast
Posts: 740
Joined: Sat Dec 03, 2011 5:54 pm
Location: Oldenburg (Germany)

Re: Debug output is terribly slow

Post 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.
PB 5.70 LTS (x64) - Debian Testing, Gnome 3.30.2
freak
PureBasic Team
PureBasic Team
Posts: 5941
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Re: Debug output is terribly slow

Post 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.
quidquid Latine dictum sit altum videtur
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: Debug output is terribly slow

Post by ts-soft »

I think your problem have to do with this: http://www.purebasic.fr/english/viewtop ... 46#p370646

Greetings - Thomas
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Re: Debug output is terribly slow

Post 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.
remi_meier
Enthusiast
Enthusiast
Posts: 468
Joined: Sat Dec 20, 2003 6:19 pm
Location: Switzerland

Re: Debug output is terribly slow

Post 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.
Athlon64 3700+, 1024MB Ram, Radeon X1600
uwekel
Enthusiast
Enthusiast
Posts: 740
Joined: Sat Dec 03, 2011 5:54 pm
Location: Oldenburg (Germany)

Re: Debug output is terribly slow

Post 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
PB 5.70 LTS (x64) - Debian Testing, Gnome 3.30.2
remi_meier
Enthusiast
Enthusiast
Posts: 468
Joined: Sat Dec 20, 2003 6:19 pm
Location: Switzerland

Re: Debug output is terribly slow

Post 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.
Athlon64 3700+, 1024MB Ram, Radeon X1600
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Re: Debug output is terribly slow

Post 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).
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Re: Debug output is terribly slow

Post 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.
uwekel
Enthusiast
Enthusiast
Posts: 740
Joined: Sat Dec 03, 2011 5:54 pm
Location: Oldenburg (Germany)

Re: Debug output is terribly slow

Post 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?
PB 5.70 LTS (x64) - Debian Testing, Gnome 3.30.2
remi_meier
Enthusiast
Enthusiast
Posts: 468
Joined: Sat Dec 20, 2003 6:19 pm
Location: Switzerland

Re: Debug output is terribly slow

Post 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.
Athlon64 3700+, 1024MB Ram, Radeon X1600
MachineCode
Addict
Addict
Posts: 1482
Joined: Tue Feb 22, 2011 1:16 pm

Re: Debug output is terribly slow

Post 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.
Microsoft Visual Basic only lasted 7 short years: 1991 to 1998.
PureBasic: Born in 1998 and still going strong to this very day!
void
Enthusiast
Enthusiast
Posts: 116
Joined: Sat Aug 27, 2011 9:50 pm
Location: Washington, USA

Re: Debug output is terribly slow

Post 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.
Post Reply