Home All Groups Group Topic Archive Search About

.NET2.0: Performance von String-Operationen

Author
23 Jan 2006 6:24 PM
Björn_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

Author
24 Jan 2006 4:48 PM
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


Show quoteHide quote
"Björn Dietz" <bjoerndi***@gmx.de> wrote in message
news:dr370r$2os$00$1@news.t-online.com...
| 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