RE: ramdisk (was: Re: Changing data types Concluded)
> -----Original Message-----
> From: Allen Robnett [mailto:alrobnett at alumni.princeton.edu]
> Subject: Re: ramdisk (was: Re: Changing data types Concluded)
>
>
>
> Derek wrote:
>
> <<As you have all the bytes in RAM, you do not have to convert them to
> Euphoria integers etc... You can use the RAM-based string
> searching routines
> built in to Windows.
>
> <snip>
> while offset < FileSize do
> result = c_func(CompareString,{0, 0, RAMADDR+offset, len,
> FindStr, len})
> if result = CSTR_ERROR or result = CSTR_EQUAL then
> exit
> end if
> offset += recsize
> end while
> >>
>
> Euman wrote:
>
> << Make sure you free that allocated string. >>
>
> Kat wrote:
>
> <<No, it means it took 14 sec to find it each time. Which
> sounds bad to me,
> because it means a 200meg file will take about 6 minutes to
> find a record at
> the end. There must be a gotcha somewhere.>>
>
> Many thanks to all for the generous assistance.
> Using Derek's suggested CompareString on my 200MB+ file
> (Pentium 4, 2.53 GHz, 512MB RAM) I got 7.69 seconds for a
> 4-character search string and 8.36 seconds for a 12-character
> search string. (The majority of the fields contained simply
> underscores. The target string was in the last 12-character
> record, number 16,777,216, ending with byte number 201,326,592.)
>
> Modifying the while statement to:
>
> while offset < FileSize and c_func(CompareString,{0, 0,
> RAMADDR+offset, len, FindStr, len}) != CSTR_EQUAL do
> offset += recsize
> end while
>
> resulted in a only a very slight improvement: 7.30 seconds.
CompareString() is a *very* expense method as it takes regional locale
aspects into consideration. It might be better to get a small machine-code
routine written to scan from a RAM address for the first occurance of the
target string.
--
Derek
|
Not Categorized, Please Help
|
|