Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Vilhelm-Ion Praisach
  Where is Vilhelm-Ion Praisach?
 Resita
 Romania
 Vilhelm-Ion Praisach
 To: Pete Sass
  Where is Pete Sass?
 Marathon, Ontario
 Canada
 Pete Sass
 Tags
Subject: RE: C++ compiler
Thread ID: 415740 Message ID: 416076 # Views: 44 # Ratings: 0
Version: Visual FoxPro 9 SP2 Category: 3rd Party Software
Date: Saturday, December 20, 2014 9:18:10 PM         
   


> >
> > This is my test.
> >
> >
LOCAL lnmult,cc[4],lni,lnRecno,ttt,lnRec
> > CLEAR
> > CLOSE DATABASES ALL
> > RAND(-1)
> > SET DELETED OFF && ON
> > lnRecno = 100
> > FOR lnmult = 1 TO 3 && 4 && 5
> > 	cc[m.lnmult] = SYS(2015)
> > 	CREATE TABLE (cc[m.lnmult]) (ii I,cc C(10))
> > 	lnRecno = m.lnRecno * 10 && 1000, 10000, 100000, 1000000, 10000000
> > 	?
> > 	? ' cursor with ' + TRANSFORM(m.lnRecno) + 'rows'
> > *!*		APPEND BLANK
> > *!*		DELETE
> > 	FOR lni = 1 TO m.lnRecno
> > 		INSERT INTO (cc[m.lnmult]) VALUES (m.lni,SYS(2015))
> > 	NEXT
> > *!*		APPEND BLANK
> > *!*		DELETE
> > 
> > *!*		INDEX on cc TAG cc DESCENDING
> > *!*		SET ORDER TO cc
> > 
> > *!*		SET FILTER TO ii % 100 = 0
> > 	
> > 	? "1000 go bottom, step " + TRANSFORM(10 ^(m.lnmult-1))
> > 	ttt = SECONDS()
> > 	FOR lnRec = 1 TO 1000
> > 		GO MAX(m.lnRec * 10 ^(m.lnmult-1),1)
> > 		SKIP -1
> > 		GO BOTTOM 
> > 	NEXT
> > 	? SECONDS() - ttt
> > 	
> > 	? "1000 locate .F., step " + TRANSFORM(10 ^(m.lnmult-1))
> > 	ttt = SECONDS()
> > 	FOR lnRec = 1 TO 1000
> > 		GO MAX(m.lnRec * 10 ^(m.lnmult-1),1)
> > 		SKIP -1
> > 		LOCATE FOR .F.
> > 	NEXT
> > 	? SECONDS() - ttt
> > 
> > 	? "1000 go bottom, random"
> > 	ttt = SECONDS()
> > 	FOR lnRec = 1 TO 1000
> > 		GO MAX(INT(m.lnRecno * RAND()),1)
> > 		SKIP -1
> > 		GO BOTTOM 
> > 	NEXT
> > 	? SECONDS() - ttt
> > 	
> > 	? "1000 locate .F., random"
> > 	ttt = SECONDS()
> > 	FOR lnRec = 1 TO 1000
> > 		GO MAX(INT(m.lnRecno * RAND()),1)
> > 		SKIP -1
> > 		LOCATE FOR .F.
> > 	NEXT
> > 	? SECONDS() - ttt
> > 
> > 	FOR lni = 1 TO m.lnRecno
> > 		APPEND BLANK
> > 	NEXT
> > 	? "1000 go top, step " + TRANSFORM(10 ^(m.lnmult-1))
> > 	ttt = SECONDS()
> > 	FOR lnRec = 1 TO 1000
> > 		GO m.lnRec * 10 ^(m.lnmult-1)
> > 		SKIP -1
> > 		GO TOP
> > 	NEXT
> > 	? SECONDS() - ttt
> > 	
> > 	? "1000 locate, step " + TRANSFORM(10 ^(m.lnmult-1))
> > 	ttt = SECONDS()
> > 	FOR lnRec = 1 TO 1000
> > 		GO m.lnRec * 10 ^(m.lnmult-1)
> > 		SKIP -1
> > 		LOCATE 
> > 	NEXT
> > 	? SECONDS() - ttt
> > 
> > 	? "1000 go top, random"
> > 	ttt = SECONDS()
> > 	FOR lnRec = 1 TO 1000
> > 		GO MAX(INT(m.lnRecno * RAND()),1)
> > 		SKIP -1
> > 		GO TOP 
> > 	NEXT
> > 	? SECONDS() - ttt
> > 	
> > 	? "1000 locate, random"
> > 	ttt = SECONDS()
> > 	FOR lnRec = 1 TO 1000
> > 		GO MAX(INT(m.lnRecno * RAND()),1)
> > 		SKIP -1
> > 		LOCATE
> > 	NEXT
> > 	? SECONDS() - ttt
> > NEXT

> >
> > Respectfully
>
>
> Hi Vilhelm,
>
> Interesting as your elapse timing adds more with what one would experience
> in a real-work application "where-as" my code only looks at the actual
> two commands and their times.
>
> The other thing you need to do is not introduce the FOR condition
> LOCATE FOR .F.
> is a different thing when compared against
> LOCATE = .F.
>
> One can easily see the speed improvement by dropping the FOR condition in
> your code example and re-run to see what impact FOR has..
>
> Below are parts times with the FOR condition removed . . .
>
>
> Based upon my testing and yours I honestly do not see any major speed advantage to either
> one, but it seems like the GOTO BOTTOM for the most part edges out ahead in speed. So
> little difference though either one would work almost interchangeably.
> I went with GOTO BOTTOM several years ago as at that time as I recall this back then in my
> testing GOTO BOTTOM had a very slight speed advantage over the LOCATE = .F.
>
> So which one you going to use ? ;-) ;-) ;-) ;-)
>
> Pete "the IceMan", from the Great White North of Canada.
> www.marathongriffincomputers.com

Hi Pete,

I posted the test without comments, because, like you, I also was intrigued.
It's my first test, and I'm not very sure if I did it right.
I also tried SET FILTER, SET DELETED...
I guess Locate = .F. don't move the record pointer, but creates a memory variable named Locate and give them the value .F., instead.
I remember I read that LOCATE is faster than Go Top only under some certain conditions, and slower in rest.

Respectfully

ENTIRE THREAD

C++ compiler Posted by Mike Yearwood @ 12/11/2014 9:47:42 PM
RE: C++ compiler Posted by Tony Vignone @ 12/11/2014 10:18:16 PM
RE: C++ compiler Posted by michael johnson @ 12/12/2014 3:15:14 AM
RE: C++ compiler Posted by Mike Yearwood @ 12/12/2014 4:40:18 PM
RE: C++ compiler Posted by Chuanbing Chen @ 12/12/2014 8:01:24 AM
RE: C++ compiler Posted by Pete Sass @ 12/12/2014 12:41:53 PM
RE: C++ compiler Posted by Pete Sass @ 12/13/2014 5:29:47 PM
RE: C++ compiler Posted by Tony Vignone @ 12/13/2014 8:27:53 PM
RE: C++ compiler Posted by Chuanbing Chen @ 12/14/2014 3:44:09 AM
RE: C++ compiler Posted by Mike Yearwood @ 12/15/2014 4:02:35 PM
RE: C++ compiler Posted by Tony Vignone @ 12/16/2014 2:10:42 PM
RE: C++ compiler Posted by Mike Yearwood @ 12/16/2014 6:00:18 PM
RE: C++ compiler Posted by Tony Vignone @ 12/16/2014 7:37:14 PM
RE: C++ compiler Posted by Pete Sass @ 12/17/2014 3:27:15 AM
RE: C++ compiler Posted by Mike Yearwood @ 12/17/2014 3:50:23 PM
RE: C++ compiler Posted by Pete Sass @ 12/17/2014 6:09:24 PM
RE: C++ compiler Posted by Mike Yearwood @ 12/18/2014 3:22:37 PM
RE: C++ compiler Posted by Pete Sass @ 12/18/2014 4:55:58 PM
RE: C++ compiler Posted by Mike Yearwood @ 12/18/2014 7:16:44 PM
RE: C++ compiler Posted by Pete Sass @ 12/18/2014 7:53:51 PM
RE: C++ compiler Posted by Chuanbing Chen @ 12/19/2014 12:48:30 AM
RE: C++ compiler Posted by Pete Sass @ 12/19/2014 11:57:43 PM
RE: C++ compiler Posted by Mike Gagnon @ 12/20/2014 2:09:13 AM
RE: C++ compiler Posted by Pete Sass @ 12/20/2014 3:18:09 PM
RE: C++ compiler Posted by Vilhelm-Ion Praisach @ 12/20/2014 6:53:41 PM
RE: C++ compiler Posted by Pete Sass @ 12/20/2014 8:25:14 PM
RE: C++ compiler Posted by Vilhelm-Ion Praisach @ 12/20/2014 9:18:10 PM
RE: C++ compiler Posted by Mike Yearwood @ 12/22/2014 3:01:11 PM
RE: C++ compiler Posted by Pete Sass @ 12/22/2014 3:57:28 PM
RE: C++ compiler Posted by Vilhelm-Ion Praisach @ 12/22/2014 5:54:52 PM
RE: C++ compiler Posted by Mike Yearwood @ 12/22/2014 9:38:06 PM
RE: C++ compiler Posted by Chuanbing Chen @ 12/23/2014 1:03:49 AM
RE: C++ compiler Posted by Mike Yearwood @ 12/22/2014 3:42:43 PM