.NET2.0: Performance von String-Operationen

  • Thread starter =?ISO-8859-15?Q?Bj=F6rn_Dietz?=
  • Start date
?

=?ISO-8859-15?Q?Bj=F6rn_Dietz?=

Hello,

does someone have experience concerning the performance with string
operations in .net2?

for example, which code (a or b) is quicker when executed a million times:

a)
DIM x1 AS STRING = " TEST "
DIM x2 AS STRING = TRIM(x1)

b)
DIM x1 AS STRING = " TEST "
DIM x2 AS STRING = x1.TRIM

I have to parse through very large files, so even a small difference
would make a significant difference for the final program.

thanks in advance!

bjoern
 
J

Jay B. Harlow [MVP - Outlook]

Björn,
Why not setup a couple of test programs & find out?

For timing .NET 1.x programs I normally use QueryPerformanceCounter:

http://support.microsoft.com/kb/306978/en-us

In .NET 2.0 I normally use the new StopWatch class.

http://msdn2.microsoft.com/en-us/library/system.diagnostics.stopwatch.aspx


However!! rather then worry if VB.Trim is faster then String.Trim up front.
I would worry about writing the program first, at least prototype the
program first. Then use either CLR Profiler or another profiling tool to
find the bottlenecks. I would then optimize those bottle necks.

--
Hope this helps
Jay [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net


| Hello,
|
| does someone have experience concerning the performance with string
| operations in .net2?
|
| for example, which code (a or b) is quicker when executed a million times:
|
| a)
| DIM x1 AS STRING = " TEST "
| DIM x2 AS STRING = TRIM(x1)
|
| b)
| DIM x1 AS STRING = " TEST "
| DIM x2 AS STRING = x1.TRIM
|
| I have to parse through very large files, so even a small difference
| would make a significant difference for the final program.
|
| thanks in advance!
|
| bjoern
 

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

Top