473,508 Members | 2,088 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

String vs. Stringbuilder speed parsing questio

Hi everyone,
Can you help me please? Say you have hashtable of about 500 key/value
pairs. This hashtable has to parse a word. If the word matches the key
the then said word must be replaced by the value.
My question is though - would parsing occur faster if the word is
input as a type string or a type stringbuilder? Do you see my point?
Would appreciate any comments/experiences/suggestions that anyone has
on this one...

Al.

Feb 7 '06 #1
4 2104
Your best bet is to test. StringBuilder are faster if you have significants
processing to do on a string and/or if those strings are big.

Here I don't really see what you mean (do you mean you would use
stringbuilders as keys instead of strings hoping it would speed up data
retrieval, if yes IMO you won't see any difference). For a start you can try
to time your code to see what is the slowest part...

--
Patrice

<al*****@altavista.com> a écrit dans le message de
news:11**********************@g44g2000cwa.googlegr oups.com...
Hi everyone,
Can you help me please? Say you have hashtable of about 500 key/value
pairs. This hashtable has to parse a word. If the word matches the key
the then said word must be replaced by the value.
My question is though - would parsing occur faster if the word is
input as a type string or a type stringbuilder? Do you see my point?
Would appreciate any comments/experiences/suggestions that anyone has
on this one...

Al.

Feb 7 '06 #2
Hi Al,

The hash table is fine with String. The StringBuilder is mostly used to
build strings concatenating small strings many times or replacing/inserting
text inside a large string, so you have to see if this fits in your problem,
which surely does for replacing the words by the new ones in the paragraph
that you want to process.
--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio
You can code, design and document much faster:
http://www.mztools.com
<al*****@altavista.com> escribió en el mensaje
news:11**********************@g44g2000cwa.googlegr oups.com...
Hi everyone,
Can you help me please? Say you have hashtable of about 500 key/value
pairs. This hashtable has to parse a word. If the word matches the key
the then said word must be replaced by the value.
My question is though - would parsing occur faster if the word is
input as a type string or a type stringbuilder? Do you see my point?
Would appreciate any comments/experiences/suggestions that anyone has
on this one...

Al.

Feb 7 '06 #3
Al,

A string is an immutable string of characters
A stringbuilder is a muttable string of characters. Therefore it needs at
least instructions to set it to an immutable string of charaters that you
probably need. (ToString)

Cor
Feb 7 '06 #4
Patrice, Carlos & Cor - thank you all for your comments.

Cheers,
Al.

Feb 7 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

37
4653
by: Kevin C | last post by:
Quick Question: StringBuilder is obviously more efficient dealing with string concatenations than the old '+=' method... however, in dealing with relatively large string concatenations (ie,...
2
460
by: Zach Tong | last post by:
I recently ran our code through a profiler to determine why it was using so much memory. It turns out the System.String object is taking 95% of the memory. We have considered converting the...
12
2428
by: Tee | last post by:
String Builder & String, what's the difference. and when to use which ? Thanks.
10
2699
by: klineb | last post by:
Good Day, I have written and utility to convert our DOS COBOL data files to a SQL Server database. Part of the process requires parsing each line into a sql statement and validting the data to...
12
2690
by: Richard Lewis Haggard | last post by:
I thought that the whole point of StringBuilder was that it was supposed to be a faster way of building strings than string. However, I just put together a simple little application to do a...
26
3154
by: Hardy Wang | last post by:
Hi all, I know it is better to handle large string with a StringBuilder, but how does StringBuilder class improve the performance in the background? Thanks! -- WWW:...
9
1913
by: Michael D. Ober | last post by:
OK, I can't figure out a way to optimize the following VB 2005 code using StringBuilders: Public Const RecSize as Integer = 105 Private buffer As String Public Sub New() init End Sub...
15
50136
by: morleyc | last post by:
Hi, i would like to remove a number of characters from my string (\t \r \n which are throughout the string), i know regex can do this but i have no idea how. Any pointers much appreciated. Chris
34
3488
by: raylopez99 | last post by:
StringBuilder better and faster than string for adding many strings. Look at the below. It's amazing how much faster StringBuilder is than string. The last loop below is telling: for adding...
0
7226
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7125
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7388
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
4709
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3199
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3186
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1561
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
767
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
422
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.