Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Optimize Program
Message
 
To
16/05/2002 18:04:52
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00657743
Message ID:
00658172
Views:
18
>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
Wayne Myers, MCSD
Senior Consultant
Forte' Incorporated
"The only things you can take to heaven are those which you give away" Author Unknown
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform