String.Replace faster in C++ then vb?

  • Thread starter Thread starter buu
  • Start date Start date
B

buu

I have an function that replaces some string from a huge text that I run
very often...
So, I wanted to speed it up... I was using String and StringBuilder.
But, I was wandering should same function in c++ be faster?

I tried to test it and it wasn't...
why?
Is there any example of faster functions in VC than in VB? (using c++ or c)
 
I doubt you'd find any performance difference if you use the same .NET
classes via C++/CLI - the IL code being executed is either identical or very
close. To get better performance, use the native C++ string methods.
--
http://www.tangiblesoftwaresolutions.com
C++ to C#
C++ to VB
C++ to Java
VB & C# to Java
Java to VB & C#
Instant C#: VB to C#
Instant VB: C# to VB
Instant C++: VB, C#, or Java to C++/CLI
 
buu said:
I have an function that replaces some string from a huge text that I run very often...
So, I wanted to speed it up... I was using String and StringBuilder.
But, I was wandering should same function in c++ be faster?

I tried to test it and it wasn't...
why?
Is there any example of faster functions in VC than in VB? (using c++ or c)

Be sure this isn't a case of "premature optimization". Do you perceive a bottleneck in this section of code? Have you profiled your
application to determine exactly how much time the string replacement is taking relative to the rest of your code?

The reason I point this out is that it is a common mistake to assume a section of code is taking "a long time" when in fact there
may be greater benefit in optimizing other sections of code. Profiling is the only way to be sure you are focusing attention in the
right area.
 
David said:
I doubt you'd find any performance difference if you use the same .NET
classes via C++/CLI - the IL code being executed is either identical
or very close. To get better performance, use the native C++ string
methods. --

On top of that, most of the implementation of System.String is in fact
written in C++. The managed class is mostly just a metadata wrapper around
native methods.

-cd
 
tnx a lot to all your posts.

well, the answers are:
- I have profiled my app. and this 'String replacement' is taking almost 20%
of cpu (let's say it takes minimum 10%)
- I also tried other ways like putting indexes (lower & upper) wich parts of
text should be ignored... there's no opmimization in this part, caus
determining those indexes is almoust the same like replacing (thus you need
to take care of those indexes)


well, only thing for replace that does seems to might be faster is using
Regex.
Is it faster?
 
Back
Top