Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Faster (0 - num) or (num * -1)
Message
De
20/11/2003 17:11:35
 
 
À
20/11/2003 16:53:38
Mike Yearwood
Toronto, Ontario, Canada
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00851967
Message ID:
00852101
Vues:
18
>What is the performance of -m.x (without a zero)?

interesting, didn't know you could do that in vfp.

the following (updated) test show that we now have a full second (on my toaster - p4 1.6 Ghz) between the fastest and the slowest solution.

the fastest is
store -m.pnx to t
with 2.3540 seconds, and the slowest is
t = pnx * (-1)
with 3.3050 seconds.

here is the test:
clear
_Screen.LockScreen = .t.
_vfp.Autoyield = .f.

* *** *******************************
* *** test 1
clear all
release all
use inv
t = 0
pnx = 7
starttime = seconds()
for i=1 to 5000000
	t = pnx * (-1)
endfor
?"pnx * (-1)              = " + str(seconds() - starttime, 8, 4)

* *** *******************************
* *** test 2
clear all
release all
use inv
t = 0
pnx = 7
starttime = seconds()
for i=1 to 5000000
	t = 0 - pnx
endfor
?"0 - pnx                 = " + str(seconds() - starttime, 8, 4)

* *** *******************************
* *** test 3
clear all
release all
use inv
t = 0
pnx = 7
starttime = seconds()
for i=1 to 5000000
	t = -pnx
endfor
?"-pnx                    = " + str(seconds() - starttime, 8, 4)

* *** *******************************
* *** test 4
clear all
release all
use inv
t = 0
pnx = 7
starttime = seconds()
for m.i=1 to 5000000
	t = m.pnx * (-1)
endfor
?"m.pnx * (-1)            = " + str(seconds() - starttime, 8, 4)

* *** *******************************
* *** test 5
clear all
release all
use inv
t = 0
pnx = 7
starttime = seconds()
for m.i=1 to 5000000
	t = 0 - m.pnx
endfor
?"0 - m.pnx               = " + str(seconds() - starttime, 8, 4)

* *** *******************************
* *** test 6
clear all
release all
use inv
t = 0
pnx = 7
starttime = seconds()
for m.i=1 to 5000000
	t = -m.pnx
endfor
?"-m.pnx               = " + str(seconds() - starttime, 8, 4)

* *** *******************************
* *** test 7
clear all
release all
use inv
t = 0
pnx = 7
starttime = seconds()
for i=1 to 5000000
	store pnx * (-1) to t
endfor
?"store pnx * (-1) to t = " + str(seconds() - starttime, 8, 4)

* *** *******************************
* *** test 8
clear all
release all
use inv
t = 0
pnx = 7
starttime = seconds()
for i=1 to 5000000
	store 0 - pnx to t
endfor
?"store 0 - pnx to t    = " + str(seconds() - starttime, 8, 4)

* *** *******************************
* *** test 9
clear all
release all
use inv
t = 0
pnx = 7
starttime = seconds()
for i=1 to 5000000
	store -pnx to t
endfor
?"store -pnx to t       = " + str(seconds() - starttime, 8, 4)

* *** *******************************
* *** test 10
clear all
release all
use inv
t = 0
pnx = 7
starttime = seconds()
for m.i=1 to 5000000
	store m.pnx * (-1) to t
endfor
?"store m.pnx * (-1) to t = " + str(seconds() - starttime, 8, 4)

* *** *******************************
* *** test 11
clear all
release all
use inv
t = 0
pnx = 7
starttime = seconds()
for m.i=1 to 5000000
	store 0 - m.pnx to t
endfor
?"store 0 - m.pnx to t    = " + str(seconds() - starttime, 8, 4)

* *** *******************************
* *** test 12
clear all
release all
use inv
t = 0
pnx = 7
starttime = seconds()
for m.i=1 to 5000000
	store -m.pnx to t
endfor
?"store -m.pnx to t       = " + str(seconds() - starttime, 8, 4)

_Screen.LockScreen = .f.
_vfp.Autoyield = .t.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform