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'
>
> DO p_2TRG WITH m.header+m.size+m.data
> CASE m.header = '1MHG'
> DO p_1MHG WITH m.header+m.size+m.data
> CASE m.header = '4'
> 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'
> 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'
> * etc...
> CASE m.header = '7'
> * etc...
> CASE m.header = '3MTG'
> * 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"