Re: Fastest way to access data from a file.
From: Ignacio X. Domínguez (ignacioxd_at_cantv.net)
Date: 09/14/04
- Next message: Nicholas Paldino [.NET/C# MVP]: "Re: Configuration files for Services and Class Libraries"
- Previous message: gaetanog: "RE: Use class instance over solution"
- In reply to: Ignacio Machin \( .NET/ C# MVP \): "Re: Fastest way to access data from a file."
- Next in thread: Ignacio Machin \( .NET/ C# MVP \): "Re: Fastest way to access data from a file."
- Reply: Ignacio Machin \( .NET/ C# MVP \): "Re: Fastest way to access data from a file."
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 14 Sep 2004 10:23:49 -0400
Hi tocayo (hehehe), Why do you think a simple text file is better than a XML
in this case? The problem I see with the text file is the special separator
character, because it is going to limit somehow what the strings in each
entry can contain (can't have that char). Therefore, I need to make sure in
code that the strings being stored in the text file never contain that
character. I know I can use any weird character making it unlikely that it
will be chosen by any user, but there is still a chance.
What are your thoughts about this?
"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us> wrote
in message news:OzbtBXlmEHA.3608@TK2MSFTNGP09.phx.gbl...
> 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
>>
>>
>
>
- Next message: Nicholas Paldino [.NET/C# MVP]: "Re: Configuration files for Services and Class Libraries"
- Previous message: gaetanog: "RE: Use class instance over solution"
- In reply to: Ignacio Machin \( .NET/ C# MVP \): "Re: Fastest way to access data from a file."
- Next in thread: Ignacio Machin \( .NET/ C# MVP \): "Re: Fastest way to access data from a file."
- Reply: Ignacio Machin \( .NET/ C# MVP \): "Re: Fastest way to access data from a file."
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|