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 ???
timing
Moderators:Administrator, Global Moderator
-
- QBasic God
- Posts:166
- Joined:Tue Mar 25, 2003 12:45 am
- Location:U.S.A.
- Contact:
:)Re: timing
Try this...
SortTime&=Timer
' Do you sort routine....
Print Ltrim$(Str$(Timer-SortTime&))+" seconds for sort."
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!
Re: timing
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? ???
- frankiebaby
- Global Moderator
- Posts:95
- Joined:Tue Apr 30, 2002 1:38 am
- Location:Pennsylvania
- Contact:
Re: timing
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."
ST! = Timer 'start
'...LOOP CODE HERE....
ET! = Timer 'end
PRINT "Took "; ET!-ST!; "Seconds To Complete."
Re: timing
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 %.
and got something like one= 62883.15, two=62883.37 and the diffrence was .2226563 without any % or other nuts.
thanks for your help
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