string.Split() performant ?

  • Thread starter Thread starter John A Grandy
  • Start date Start date
J

John A Grandy

Is string.Split() performant to a degree that there's no point in trying to
write code to improve on its performance ?
 
Hi Peter, and thanks for the response.

What about string.Replace() ... ?

Same answer ?
 
John said:
Is string.Split() performant to a degree that there's no point in trying
to write code to improve on its performance ?

In general you should expect that MS has optimized
all the mostly used methods. I am sure that they run
profilers on .NET apps and see where in the library
there are bottlenecks.

A quick look at the source code gives me the impression that
the code is fast but use some memory.

Given that I find it very unlikely that you will be
able to write some split code that will increase
your app code measurable. It is much more likely
that you will be able to increase maintenance cost !

Arne
 
How can I use a profiler ( e.g. RedGate ANTS Profiler ) to breakdown
relative performance of method calls inside giant iterations ? ( i.e.
implement 3 different algorithms and/or coding techniques and see which one
is taking the least time on avg per iteration )
 
Hi Peter, and thanks for the response.

What about string.Replace() ... ?

Same answer ?

Modulo the observation that StringBuilder.Replace may be a better fit
for your application (if you do multiple replaces on the same string,
then string.Replace will generate lots of different strings, whereas
the StringBuilder one won't), almost certainly yes.

It does depend what your application is. My guess is that the
framework is optimized for Split/Replace on strings a few k's long.
If your data is 100 MBytes, there may be other operations (like
splitting in place), that would be worthwhile.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top