Qbasicnews.com

Full Version: QBX faster than FB?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
tell me if i am doing something wrong, i did compile this in QBX and in freebasic just writing: FBC CODE.BAS
Code:
aaa = TIMER
FOR bbb = 1 TO 100000: LOCATE , 1: PRINT bbb; : NEXT
PRINT
PRINT TIMER - aaa
BEEP
END
in QBX the time it's two or three seconds
in FB the time it's forty or forty five seconds
why?
What makes slow your program is the console i/o (PRINT)..
If you try a CPU- intensive program, FB compares with C compilers..
See
http://forum.qbasicnews.com/viewtopic.php?t=7507
if QBX it is more primitive than FB, isn't that a bug in FB?
The following applies to Windows NT/2K/XP, I think.

I think that 32-bit Windows programs use the internal Windows console functions, while 16-bit MS-DOS programs use a DOS emulator to run. The Windows console functions update the display with each call of a console function, while the DOS emulator only updates the display every once in a while, so during the time the DOS emulator is not updating the display, QB is still outputting stuff, but has more time to do so, because of the state of the window.

That's a complete guess, and it's 5:45 AM and I have to go to school in a couple hours. Sad
DOS console is faster than Windows console.
Also FB seems to have some bottleneck in the implementation of LOCATE
All of this has already been discussed and is well-known information. No new light is being shed here, guys. Big Grin
Try this to actually know the speed between QB and FB.
I didn't have QB, so can't tell the different.

Code:
aaa = TIMER
PRINT "begin counting"

'test1: -0.015 second
'-------------------------------------
'bbb=0
'redo:
'  bbb=bbb+1
'  IF( bbb < 100000 ) THEN GOTO redo
'  PRINT bbb
'-------------------------------------

'test2: -0.048 second
'-------------------------------------
FOR bbb=1 TO 100000: ccc=bbb: NEXT
PRINT ccc
'-------------------------------------

PRINT "end counting"
PRINT TIMER - aaa
input "press ENTER to exit", k
'BEEP
END

remark/un-remark between 2 test section to compare.

ps - testing was made on P3-450Mhz W95OCR2
Ladies and gentlemen, I present: the time travelling computer! Gather 'round, and witness it's awesome glory!
The above code outputted:
Code:
begin counting
100000
end counting
-0.266
press ENTER to exit
I've run the program several times - it's usually positive, but about 2-3 times now it's been negative :o. I don't see anything wrong with the code... FreeBASIC bug?

Athlon XP 3200+ 400 Mhz FSB, PC3200 DDR ram, Windows XP
Or maybe my computer is SO FAST, that it finishes before it starts! 8) Yeah, that's it.
it's not a bug. it so fast when [aaa = TIMER] not yet finished registered, counting was done. so, [TIMER-aaa] is timer done before aaa stored in the register.

imagine, how fast the processor is. multiply those with 100000, you could travel 'back to the future' Big Grin
rtlib calls GetTickCount() do to the work, i guess it's not updated so fast by Windows -- i don't know the inner works, but if Pentium's read counter thing is set as a privileged operation, GetTickCount() won't switch to kernel mode to read it, probably there's some kind of pooling or something.. only M$ knows :P

And yeah, Windows seems to idle the console apps when they do loads of prints and take 100% of CPU time, dunno.
Pages: 1 2