Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Faster (0 - num) or (num * -1)
Message
From
20/11/2003 16:53:38
Mike Yearwood
Toronto, Ontario, Canada
 
 
To
20/11/2003 14:23:32
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00851967
Message ID:
00852092
Views:
18
What is the performance of -m.x (without a zero)?



>Yes, it would be interesting what other people have to say about this! "HEY DAVID, CAN YOU HEAR US?" <vbg>
>
>but seriously, i've added to my testing routing to include the testing between variables with 'm.' and without (remembering a heated discussion here on UT a while back). back then i got the feeling from that thread, that it would be faster to use 'm.' very carfully and with certain rules.
>
>well, i've got the proof in the following test. BUT, looking at the results, we're talking about a minimal advantage, that i question the need to even talk about it.
>
>taking in consideration that i have to loop 5 million times in order to see some difference, well...
>
>here is the test. please change "use inv" to a table of your choice and change the 'pnx' to a field name + "x".
>clear
>_Screen.LockScreen = .t.
>_vfp.Autoyield = .f.
>
>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)
>
>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)
>
>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)
>
>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)
>
>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)
>
>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)
>
>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)
>
>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)
>
>_Screen.LockScreen = .f.
>_vfp.Autoyield = .t.
>
>
>
>>Same to me, may be its time to change to the new old-fashioned stuffs. It would be interesting to see what David F. say about it (he's the king of speed testing to me)
>>
>>>you are welcome <s>
>>
>>>what is interesting to me is, that the old 'store' command is faster then the '='. i never us 'store' because i don't like the redability in the code. i think it's easier to read/follow the code if '=' is used.
>>
>>>>That's correct, it seems like a delay with RAND() function. Thank's for the Heads Up :-)
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform