Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Argument starter - The roots of all evil
Message
De
09/09/2004 13:46:51
 
 
À
09/09/2004 11:23:43
Walter Meester
HoogkarspelPays-Bas
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00938079
Message ID:
00940739
Vues:
29
Changed it slightly and still the results are not drastically different in VFP8:

DO WHILE: 00:00:49
FOR/ENDFOR: 00:00:46
CLEAR
SET TALK OFF
SET SAFETY OFF


CREATE TABLE mytable (nvalue n(5,0), cvalue c(10))
SELE mytable
FOR i = 1 TO 50000
	APPEND BLANK
	REPLACE mytable.nvalue WITH i
ENDFOR

SELE mytable
GO TOP
mval = 0
? "DO WHILE LOOP"
? "START1:"
time1 = DATETIME()
?? time1
DO WHILE !EOF()
	WAIT WINDOW "Processing "+ALLTRIM(STR(mval))+" of 50,000" NOWAIT
	DO countit WITH mval
   REPLACE mytable.nvalue WITH nvalue+1
	IF EMPTY(mytable.cvalue)
		REPLACE mytable.cvalue WITH "TEST1"
	ELSE
		REPLACE mytable.cvalue WITH "TEST2"
	ENDIF
	IF !CHECKIT(RECNO())
		EXIT
	ENDIF
	IF mval > 999998
		EXIT
	ENDIF
   SKIP
ENDDO
time2 = DATETIME()
timegone = timepassed(time1,time2)
? "FINISH:"
?? time2
? "TIME ELAPSED: "
?? timegone

?
?
?

SELE mytable
GO TOP
mval = 0
? "FOR ENDFOR"
? "START2:"
time1 = DATETIME()
?? time1
FOR i = 1 TO RECCOUNT()
	WAIT WINDOW "Processing "+ALLTRIM(STR(mval))+" of 50,000" NOWAIT
	DO countit WITH mval
	REPLACE mytable.nvalue WITH nvalue + 1
	IF EMPTY(mytable.cvalue)
		REPLACE mytable.cvalue WITH "TEST1"
	ELSE
		REPLACE mytable.cvalue WITH "TEST2"
	ENDIF
	IF !CHECKIT(RECNO())
		EXIT
	ENDIF
	IF mval > 999998
		EXIT
	ENDIF
	SKIP
ENDFOR
time2 = DATETIME()
timegone = timepassed(time1,time2)
? "FINISH:"
?? time2
? "TIME ELAPSED: "
?? timegone


FUNCTION checkit
LPARAMETERS recordno
IF RECNO() <> recordno
	GOTO recordno
ENDIF
IF EMPTY(mytable.nvalue)
	? RECNO()
ENDIF
RETURN .T.

PROCEDURE countit
LPARAMETERS newval
newval = newval + 1
RETURN newval

PROCEDURE timepassed
LPARAMETERS starttime, endtime
timetaken = endtime - starttime
x = ttoc( { 00:00 } + timetaken, 1)
x = substr(x,9,2) + ':' + substr(x,11,2) + ':' + right(x,2)
RETURN x
.·*´¨)
.·`TCH
(..·*

010000110101001101101000011000010111001001110000010011110111001001000010011101010111001101110100
"When the debate is lost, slander becomes the tool of the loser." - Socrates
Vita contingit, Vive cum eo. (Life Happens, Live With it.)
"Life is not measured by the number of breaths we take, but by the moments that take our breath away." -- author unknown
"De omnibus dubitandum"
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform