Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
MDot / By design
Message
De
05/01/2004 06:50:16
 
 
À
04/01/2004 20:42:15
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00863704
Message ID:
00863796
Vues:
29
Hi Jim,
>Your assumption **may** be correct as regards the operation without a selected table being similar to the WITH/ENDWITH construct. It has always been my **GUESS** that they are different.
>I base this assumption on two main reasons:
>1) the field vs memvar behaviour has been there since the start;
>2) the behaviour for WITH/ENDWITH has constraints well beyond that of the field/memvar mechanism.

I was only speaking of similar effects on perf, but as usual my post is to short to be un-ambigouos <g>.

>In fact it would be my guess that an aliased field name offers as fast access as unaliased. And of course there remain those cases, as the language is presently written, that **require** a SELECT regardless.

Here your guess is wrong. It takes more time to access aliased fields. But that difference can be neglected in many cases (see code on the bottom). Play with the code a bit, and you'll see, that for small apps ( < 50 tables/views/cursors) your approach is perfectly valid. Between 100 and 300 open work areas the effects grow quite a bit. The IMHO interesting tidbit is the growth rate: try it with 1000 tables and more. I haven't tested the effect of opening tables in different datasessions, but I've worked on applications where in most datasessions the number of open work areas was 100 at the lowest. The degradation can be seen there - that's one of the cases where expertise with the fox begins to be needed. Some developers won't test/time at all, and even some of the better developers might miss important "facts of the fox" and use coding standards which ***could*** slow down the app.

>But I rather like the idea of being able to minimized it's need AS WELL.
As long as the app doesn't suffer I'm all with you.


my 0.02 EUR

thomas
CLEAR
CLOSE DATABASES all
= creacurs()
IF .t.
	#define C__EXACT_TIMING .f.
	#if C__EXACT_TIMING
		SET PROCEDURE TO ..\..\_commonTG\prg\timing additive
		= queryPerf_Setup()
	#endif
	private ;
		pnRun, pnStop, pnTestNum, puVal, pnAppSize, pnOps, pnOpsStop, pnMeasure, ;
		pcCursname, ;
		paStartMS, paEndMS, paFuncs, paUsed 
	pnMeasure = 300
	DIMENSION paStartMS[m.pnMeasure], paEndMS[m.pnMeasure], paFuncs[m.pnMeasure], paUsed[1]
	pnStop = 3000
	pnTestNum = 0
	pnOpsStop = 20
	pnAppSize = 2
	pcCursName = "MyCurs"
	
	= TestSuite()

	LOCAL lnGrowth, lnTarget
	FOR lnGrowth = 5 TO 11
		lnTarget = INT(m.pnAppSize**m.lnGrowth)
		? "creating temp. Cursors:", m.lnTarget
		FOR pnRun = 1 TO m.lnTarget
			= creacurs("Dummy" + PADL(ALLTRIM(STR(m.pnRun, 6, 0)), 4, "0"))
		NEXT
		SELECT myCurs
		= TestSuite()	

	NEXT
	
	
	FOR pnRun = 1 TO ALEN(paStartMS, 1)
		IF VARTYPE(paStartMS[m.pnRun]) == "N"
			? paFuncs[m.pnRun]
		endif
	NEXT
	
else
	= anylib()
	myCurs = createobject("custom")
	= ADDPROPERTY(myCurs, "cMyField", "in Object")
	? m.myCurs.cMyField, myCurs.cMyField
	*-- simulate m.mycurs will be evaluated first!
	USE IN myCurs
	*-- this would use the objects property under Peter's rule
	= anylib()
	myCurs.cMyField = 5
	*-- errors are WELCOME here!
	= anylib()
ENDIF

#if C__EXACT_TIMING
#else
FUNCTION getTime_ms()
return seconds()*1000
#endif

function testsuite()
	? "Begin Testsuite, Reads:" + STR(m.pnStop*m.pnOpsStop, 11)
	= isselected()
	= withOpSelect()	
	= withOpSelectString()	
	= WithoutSelect()
	= withAlwaysSelect()
	= WithEval()

FUNCTION isselected()
	LOCAL lnOldSel
	lnOldSel = SELECT()
	SELECT myCurs
	= testStart()
	FOR pnRun = 1 TO m.pnStop
		FOR pnOpRun = 1 TO m.pnOpsStop
			puVal = nMyNum
		next
	NEXT
	SELECT (m.lnOldSel)
	= testStop()

FUNCTION withOpselect()
	LOCAL lnOldSel
	= testStart()
	FOR pnRun = 1 TO m.pnStop
		lnOldSel = SELECT()
		SELECT myCurs
		FOR pnOpRun = 1 TO m.pnOpsStop
			puVal = nMyNum
		NEXT
		SELECT (m.lnOldSel)
	NEXT
	= testStop()

FUNCTION withOpselectString()
	LOCAL lnOldSel
	= testStart()
	FOR pnRun = 1 TO m.pnStop
		lnOldSel = SELECT()
		SELECT (m.pcCursname)
		FOR pnOpRun = 1 TO m.pnOpsStop
			puVal = nMyNum
		NEXT
		SELECT (m.lnOldSel)
	NEXT
	= testStop()

FUNCTION withAlwaysSelect()
	LOCAL lnOldSel
	= testStart()
	FOR pnRun = 1 TO m.pnStop
		FOR pnOpRun = 1 TO m.pnOpsStop
			lnOldSel = SELECT()
			SELECT myCurs
			puVal = nMyNum
			SELECT (m.lnOldSel)
		next
	NEXT
	= testStop()

FUNCTION withoutselect()
	= testStart()
	FOR pnRun = 1 TO m.pnStop
		FOR pnOpRun = 1 TO m.pnOpsStop
			puVal = MyCurs.nMyNum
		next
	NEXT
	= testStop()

FUNCTION withEval()
	= testStart()
	FOR pnRun = 1 TO m.pnStop
		FOR pnOpRun = 1 TO m.pnOpsStop
			puVal = EVALUATE(m.pcCursName + ".nMyNum")
		next
	NEXT
	= testStop()

FUNCTION TestStart()
	pnTestNum = m.pnTestNum + 1
	paStartMS[m.pnTestNum] = getTime_ms()

FUNCTION TestStop()
	paEndMS[m.pnTestNum] = getTime_ms()
	paFuncs[m.pnTestNum] = ;
		STR(paEndMS[m.pnTestNum] - paStartMS[m.pnTestNum], 17, 3) + ;
		Str(aUSed(paUsed), 6) + ;
		STR(m.pnStop*m.pnOpsStop, 11) + ;
		" "  + program(PROGRAM(-1)-1) 

FUNCTION creacurs(tcName)
IF EMPTY(tcName)
	tcName = "myCurs"
endif
CREATE CURSOR (m.tcName) (cMyField C(20), nMyNum N(5))
INSERT INTO (m.tcName) (cMyField, nMyNum) VALUES ("MyField in MyCurs", 5)

FUNCTION anylib
*-- Supposed to work on the cursor field
? ALLTRIM(myCurs.cMyField)
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform