Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Can this code be faster?
Message
From
28/10/2003 15:59:19
 
 
To
28/10/2003 15:53:05
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00842920
Message ID:
00843776
Views:
18
Thanks for the ideas Thomas. I'll give them all a try!

>Hi Tracy,
>
>I believe you should measure just the performance of the fread() and the
>following case without calling the specific import programs to get an idea of times spent there.
>
>Possibly more time is spent in the other programs...
>
>That said: Hilmars idea of simulating "buffered reads" by reading a larger part of the file is something that would have done wonders in win3-times. There I often set the file buffers (in ModulaII) by hand to fine-tune such tasks. Nowadays with read caches: try it.
>
>One thing: if the FRead() as such is much slower than your normal string functions, try reading the next header and size together with the data and split them afterwards.
>
>The next part is written under the assumption, that
>a) the different headers are evenly distributed
>b) a significant number of headers doesn't have to be processed.
>
>Checking for the non-process case ***first*** will eliminate a lot
>of case checks: Cetin is on the right track IMHO.
>
>If there are only 15 to 30 cases, I think seek() is the wrong function, if speed is of the essence.
>Method 1:
>create a cursor with fields for all "N" + Header
>Search for the Header to be processed via if fsize("N"+m.Header)>0
>and only then distibute though your case.
>
>Method 2:
>Build a String with all possible variations of "§$%"+m.Header+"/()"
>and search there with "§$%"+m.Header+"/()" $ m.pcSearchStr
>
>The calling of the worker programs can be optimized as well:
>you have (n[headeroptions]+1)/2 typical case checks.
>
>Either structure your cases in a tree like manner:
>
>
>DO CASE
>     CASE m.header = '2TRG'		
>        && new transaction, probably most called function
>	DO p_2TRG WITH m.header+m.size+m.data
>     CASE m.header = '1MHG'		&& beginning of message
>	DO p_1MHG WITH m.header+m.size+m.data
>     CASE m.header = '4'   && about 5 cases
>        Do Case
>             Case m.header = '4aaa'
>             Case m.header = '4bbb'
>             Case m.header = '4ccc'
>             Case m.header = '4ddd'
>             Case m.header = '4eee'
>        EndCase
>        * etc...
>     CASE m.header = '5'   && about 5 cases
>        Do Case
>             Case m.header = '5aaa'
>             Case m.header = '5bbb'
>             Case m.header = '5ccc'
>             Case m.header = '5ddd'
>             Case m.header = '5eee'
>        EndCase
>        * etc...
>     CASE m.header = '6'   && about 5 cases
>        * etc...
>     CASE m.header = '7'   && about 5 cases
>        * etc...
>     CASE m.header = '3MTG'             && end of message
>        * do something
>ENDCASE
>
>
>or put the name of the function to be called in the cursor you built
>for method 1. You can ¯oexpand that function name - this might be
>faster than the 9 to 12 case checks.
>
>my 0.02 EUR
>
>thomas
.·*´¨)
.·`TCH
(..·*

010000110101001101101000011000010111001001110000010011110111001001000010011101010111001101110100
"When the debate is lost, slander becomes the tool of the loser." - Socrates
Vita contingit, Vive cum eo. (Life Happens, Live With it.)
"Life is not measured by the number of breaths we take, but by the moments that take our breath away." -- author unknown
"De omnibus dubitandum"
Previous
Reply
Map
View

Click here to load this message in the networking platform