Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Slow string processing.
Message
From
14/06/1999 20:47:37
 
 
To
14/06/1999 17:48:13
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00229755
Message ID:
00229800
Views:
17
String functions are usually very fast in VFP (almost the same as C/C++). But it all depends on the nature of your processing. From my experience, there is almost always a way to write a string processing function in VFP that matches (or almost) the speed of the same processing in C/C++ (BTW, C++ with CString or std::string is usually faster than C with char*!!).

I agree with Perry Forman that in this case, the problem is the extensive use of SUBSTR and that AT will improve the speed. AT has a parameter that allows you to specify the number of occurence that you want to find and this can improve the performance a lot. The point is here to have as less as possible lines of code executed (not lines of code in the program) by VFP. Even if AT searches sequentially the string, the fact that it is doing it internally will speed up a lot your processing.

Since a field name and its value are always between two "|", you can get the placements of these "|", extract the substring and use this substring to get the field value and name. You can bypass the problem with "/|" by simply having one more variable that keeps the next position of a "/|" and testing it against the next position of a "|".

Here's another thing you may want to try and that may give very good results if there are only a few "/|":
1. Use STRTRAN to delete all "/|" and "/~". Basically, if the number of "/|" is low, this should be very fast.
2. Use CHRTRAN (not STRTRAN) to replace all "|" with chr(13). This is always extremly fast in VFP, even with strings of in the megabytes range.
3. Parse the string using MEMLINES and MLINE. (Use the third param of MLINE to speed things even more.) You can use SUBSTR for each line as you do now, because the strings are small in this case.

Vlad

>I am having a problem with string parsing in vFoxpro v6.
>
>Basically, I'm stepping through a fairly large string and extracting key and value pairs as I go.
>
>The problem is that its slow. Really slow. The performance also doesn't make sense because as the string size grows the performance degrades almost exponentially. As its basically a single loop through the string the time taken should increase linearly, so I don't know what the problem is.
>
>Is there something I should know about foxpro memory handling?
>
>I've profiled the function a bunch of times but that hasn't revealed any real bottlenecks.
>
>Thanks for any suggestions.
>
>Matt
Previous
Reply
Map
View

Click here to load this message in the networking platform