Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Faster (0 - num) or (num * -1)
Message
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00851967
Message ID:
00852186
Vues:
16
>? seconds() - lnSeconds - lnBaseTime, "test constant assignment"
>There's also a couple of other things to note. 1) you have to make sure you are really timing what you think you are timing. lnBaseTime corrects out the amount of time that the base looping takes.

I agree, so why are you treating lnBaseTime as though it is a constant? In the code below I commented out the inner-loop processing. The times keep on varying - all over the shop! For example:
1. x * -1                =   0.2810
2. 0 - x                 =   0.2660
3. m.x * -1              =   0.2810
4. 0 - m.x               =   0.2660
5. store m.x * (-1) to t =   0.2810
6. store 0 - m.x to t    =   0.2810
7. store -m.x to t       =   0.2660
8. store -m.x to m.t     =   0.2810
The only de facto way of determining how much work is required to execute a line of code is to take a snapshot of CPU clock ticks for the VFP.EXE process just before and just after the line of code of interest and determine the delta (PDH.DLL springs to mind).Whilst your use of lnBasetime is a debatable improvement it is by no means the definitive answer.
_vfp.Autoyield = .f.

clear all
release all
t = 0
x = 7
starttime = seconds()
for i=1 to 5000000
	*t = x * -1
endfor
_ClipText = "< pre >1. x * -1              = " ;
			+ str( seconds() - starttime, 8, 4 ) ;
			+ chr(13)

clear all
release all
t = 0
x = 7
starttime = seconds()
for i=1 to 5000000
	*t = 0 - x
endfor
_ClipText = _ClipText ;
			+ "2. 0 - x                 = " ;
			+ str( seconds() - starttime, 8, 4 ) ;
			+ Chr(13)

clear all
release all
t = 0
x = 7
starttime = seconds()
for m.i=1 to 5000000
	*t = m.x * -1
endfor
_ClipText = _ClipText ;
			+ "3. m.x * -1            = " ;
			+ str( seconds() - starttime, 8, 4 ) ;
			+ Chr(13)

clear all
release all
t = 0
x = 7
starttime = seconds()
for m.i=1 to 5000000
	*t = 0 - m.x
endfor
_ClipText = _ClipText ;
			+ "4. 0 - m.x               = " ;
			+ str( seconds() - starttime, 8, 4 ) ;
			+ Chr(13)

clear all
release all
t = 0
x = 7
starttime = seconds()
for m.i=1 to 5000000
	*store m.x * (-1) to t
endfor
_ClipText = _ClipText ;
			+ "5. store m.x * (-1) to t = " ;
			+ str( seconds() - starttime, 8, 4 ) ;
			+ Chr(13)

clear all
release all
t = 0
x = 7
starttime = seconds()
for m.i=1 to 5000000
	*store 0 - m.x to t
endfor
_ClipText = _ClipText ;
			+ "6. store 0 - m.x to t    = " ;
			+ str( seconds() - starttime, 8, 4 ) ;
			+ Chr(13)

clear all
release all
t = 0
x = 7
starttime = seconds()
for m.i=1 to 5000000
	*store -m.x to t
endfor
_ClipText = _ClipText ;
			+ "7. store -m.x to t    = " ;
			+ str( seconds() - starttime, 8, 4 ) ;
			+ Chr(13)

clear all
release all
t = 0
x = 7
starttime = seconds()
for m.i=1 to 5000000
	*store -m.x to m.t
endfor


_ClipText = _ClipText ;
			+ "8. store -m.x to m.t    = " ;
			+ str( seconds() - starttime, 8, 4 ) ;
			+ "< /pre >" + Chr(13)

_vfp.Autoyield = .t.

?
?
? _ClipText
censored.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform