Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Optimize Program
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00657743
Message ID:
00658221
Views:
17
I saw this after my prior reply and just had to try it < s >.

I sure was surprised at the result!

I admit that I remain so, but of course accept what I see in black and white.

Nicely done.



>>Multiple REPLACEs will be much slower than a single REPLACE.
>
>You are correct... on the magnitude of about 25-30% - Great catch!!!
>
>For any that want to test it...
>
>
>create table testrslt (nstart n(15,2), nend n(15,2), nseconds n(15,2))
>
>for j = 1 to 10
>	create table testspd (cfield1 c(25), cfield2 c(10), cfield3 c(10), cfield4 c(5))
>	for i = 1 to 10000
>		insert into testspd (cfield1) values ('THISISATESTOFTHEEMERGENCY')
>
>	next i
>	select testspd
>	go top
>
>	lnstart = seconds()
>	scan
>		replace cfield2 with substr(cfield1,1,10)
>		replace cfield3 with substr(cfield1,11,10)
>		replace cfield4 with substr(cfield1,21,5)
>	endscan
>	lnend = seconds()
>
>	insert into testrslt (nstart, nend, nseconds) values (lnstart, lnend, lnend-lnstart)
>	
>next j
>
>for j = 1 to 10
>	create table testspd (cfield1 c(25), cfield2 c(10), cfield3 c(10), cfield4 c(5))
>	for i = 1 to 10000
>		insert into testspd (cfield1) values ('THISISATESTOFTHEEMERGENCY')
>
>	next i
>	select testspd
>	go top
>
>	lnstart = seconds()
>	scan
>		replace cfield2 with substr(cfield1,1,10), cfield3 with substr(cfield1,11,10), cfield4 with substr(cfield1,21,5)
>	endscan
>	lnend = seconds()
>
>	insert into testrslt (nstart, nend, nseconds) values (lnstart, lnend, lnend-lnstart)
>	
>next j
>
>
Previous
Reply
Map
View

Click here to load this message in the networking platform