timing

Please use this Board for QBasic related requests ( file research, programming, etc.)

Moderators:Administrator, Global Moderator

Post Reply
User avatar
yacinator
Full Member
Posts:33
Joined:Sun Dec 21, 2003 12:02 am
timing

Post by yacinator » Sun Feb 01, 2004 6:38 am

ok i made a sorting program and it works great. i got this idea that maybe i could display how long the sort took. at the beggining of the sort sub i put

let t1=timer

and at the end i put

let t2=timer

in the display sub i put print t2-t1 and it sais 0 so i put
print using #.##########; t2-t1 and it sais 0.00000
i'm wonderign if it sais 0 becouse it just doesn't work or becouse i didn't put enough #'s 'couse my pc is too fast and the list is too short. can somebody please try this and answer my question please ???

Dr_Davenstein
QBasic God
Posts:166
Joined:Tue Mar 25, 2003 12:45 am
Location:U.S.A.
Contact:

:)Re: timing

Post by Dr_Davenstein » Sun Feb 01, 2004 8:25 am

Try this...

SortTime&=Timer

' Do you sort routine....

Print Ltrim$(Str$(Timer-SortTime&))+" seconds for sort."

:)
Come check out [url=http://www.freebasic.net/forum/index.php]FreeBASIC[/url]. The syntax is based on QuickBasic, but it expands to use pointers, operator overloading, etc... The list goes on and on!

User avatar
yacinator
Full Member
Posts:33
Joined:Sun Dec 21, 2003 12:02 am

Re: timing

Post by yacinator » Sun Feb 01, 2004 10:23 am

ok doc now it showed something, but what it showed was : %80335.6719 but i don't think that's how much time it took to do the calculations. oh by the way i changed the string sorttime to a number and used print using #.####. Can you please tell me why i get that number? ???

User avatar
frankiebaby
Global Moderator
Posts:95
Joined:Tue Apr 30, 2002 1:38 am
Location:Pennsylvania
Contact:

Re: timing

Post by frankiebaby » Mon Feb 02, 2004 3:03 pm

Where that percent sign came from, I dont kno, but that was not a string type, it was a  long integer. Try using a double precision number, an exclamation point. TIMER is capable of returning i think up to .01 of a second. Try this:


ST! = Timer  'start
'...LOOP CODE HERE....
ET! = Timer   'end

PRINT "Took "; ET!-ST!; "Seconds To Complete."

User avatar
yacinator
Full Member
Posts:33
Joined:Sun Dec 21, 2003 12:02 am

Re: timing

Post by yacinator » Wed Feb 04, 2004 5:30 am

frankie i got the same thing after adding ! to the end of the varible but i think i know why i get % before the number. this is probably wrong but maybe the number is so long that qb is trying to write it in scientific notation maybe. and i tried the timer with a program like this and i got an answer without a %.

Code: Select all

cls
for i=1 to 10000
print timer
select case i
case is= 1
let one= timer
case is= 10000
let two= timer
end select
next i
print one
print two
print two-one
end


and got something like  one= 62883.15, two=62883.37 and the diffrence was .2226563 without any % or other nuts.
thanks for your help

Post Reply