Re: Fastest way to access data from a file.

From: Ignacio Machin \( .NET/ C# MVP \) ("Ignacio)
Date: 09/14/04


Date: Tue, 14 Sep 2004 08:24:16 -0400

Hi tocayo :)

 The fastest way is to having it in memory, you could create a struct with
two members ( name, number) and have an ArrayList of them.. you read them at
the beggining and after that all is from memory.

 if for some reason you cannot have them in memory the best way would be
keeping a text file, not a XML, in the text file you keep one record per
line, and divide the fields using a special char. For further performance
you should put the field you will search for first and make it a fixed
length. in this way you can use String.SubString instead of String.Split

Ayway , the best way is to keep them all in memory. even so I think that the
XML is not very good idea here.

Cheers,

-- 
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Ignacio X. Domínguez" <ignacioxd@cantv.net> wrote in message
news:%23wfstEhmEHA.644@tk2msftngp13.phx.gbl...
> Hi. I'm developing a desktop application that needs to store some data in
a
> local file. Let's say for example that I want to have an address book with
> names and phone numbers in a file. I would like to be able to retrieve the
> name by searching for a given phone number the fastest I can.
>
> I have considered the posibility of using XmlTextReader with something
like:
>
> <list>
>     <item number="1234567">
>         <name>John Doe</name>
>     </item>
>     <item number="9876*">
>         <name>Jane Doe</name>
>     </item>
> </list>
>
> or a simple text file with entries separated by special characters:
>
> 1234567~John Doe%9876*~Jane Doe%
>
> and then use Split("%".ToCharArray()) to get an array of items, and then
> Split("~".ToCharArray()) on every item to get name and number.
>
> I this database will have around 200 entries (name and number in this
> example), so I would like to know which one do you think will perform
faster
> and better on most configurations.
>
> Thank you in advance.
>
> Ignacio X. Domínguez
>
>


Relevant Pages

  • [HPADM] RE: Memory bank usage
    ... I discovered that using cstm I get the right answer in one of the N4000 ... Preparing the Information Tool Log for MEMORY on path 192 File ... ... -- Converting a byte raw log file to text. ... Ignacio ...
    (HP-UX-Admin)
  • Re: paradigm locate 5.0 for 80188: insufficient memory?
    ... Ignacio G.T. wrote: ... available memory below 512K. ... If you are using a W2K machine, you can do this executing command.com ... vax, 9000 ...
    (comp.arch.embedded)