Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

.exe slower than .bas ?

Status
Not open for further replies.

Stab

Programmer
Feb 1, 2002
3
ES
Is a compiled .bas program slower than running in QBasic?
I know I just use a FOR/NEXT loop:

Tcal = TIMER
FOR b = 0 TO 1000000
NEXT b
Tcal = INT(1000 / (TIMER - Tcal))
PRINT Tcal; "loops/ms";

Qbasic4.5(.bas) : 1007 loops/ms near 1 µs
Make exe (stand alone): 280 loops/ms

(Pentium III - 550Mhz / Windows 95)
About 3.5 times slower !!!
 
I think your fraction is upside down and you're getting the reciprocal. The test is doing 1000000 loops in INT(Timer-Tcal) secs or INT(Timer-Tcal x 1000) ms. The rate is 1000000/INT(Timer-Tcal) x 1000 loops per ms. So I think it should be:

Tcal = 1000/INT(Timer-Tcal) 'loops per ms

 
Try running both in real dos. Dos .exe programs are much much slower when running with windows and thats what your compiler makes.
Run it in real dos and the .exe should be twice as fast as the .bas
 
Thanks for answers,
Ok, there was a mistake copying, it was:
Tcal = INT(1000000 / ((TIMER - Tcal)*1000))
1 mega FOR/NEXT loops divided by the time in mS.

I previously tried in a good old 466DX in Dos6.2
and the result was similar.

I'm trying now with DO/LOOP,

Tcal = TIMER
i = 0
DO
i = i + 1
LOOP UNTIL i >= 1000000
Tcal = INT(1000000 / ((TIMER - Tcal) * 1000))
PRINT Tcal; "loops/ms DO/LOOP";

and it gives me about 300 loops/ms with Qbasic45,
identical loops/ms FOR/NEXT and DO/LOOP with exe.

That's interesting.

 
Hi,
Try the programs below.
The "strange" results you got may have to do with variable definition and internal storage.

REM Prog #1
DEFLNG A-Z
Tcal# = TIMER
FOR a = 1 TO 1000000
x = a
NEXT a
PRINT TIMER - Tcal# 'Rather than getting loops/sec this just gives the time used.

REM Prog #2
DEFINT A-Z
Tcal# = TIMER
FOR a = 1 TO 1000
FOR b = 1 TO 1000
x = a
z = b
NEXT B
NEXT a
PRINT TIMER - Tcal#

The results I got were more to my expectations.
Pappy
You learn something everyday.
 
This just dawned on me: What version of Qb did u run the .bas file in? 1.1 is much faster than 4.5.
If you run the .bas under 4.5 they should be about the same speed.
Also, another reason why it may be working slower is that exe files are much much bigger than .bas files (nearly 3x the size)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top