Re: slow reading of eventlog

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Dominique Vandensteen (domi.vds_insert_at_tralala_tenforce.com)
Date: 04/26/04


Date: Mon, 26 Apr 2004 13:51:08 +0200

wellwell
a post of me long time ago:

after the very small & vs string.format discussion I did some speed tests...

loop of 1.000.000 concatenations of 5 public string variables in a class
gave following results:

result = a & b & c & d & e
+/- 420ms

result = a
result &= b
result &= c
result &= d
result &= e
+/- 370ms

dim result as new StringBuilder()
result.Append(a)
result.Append(b)
result.Append(c)
result.Append(d)
result.Append(e)
new StringBuilder in each loop: +/- 730ms
new StringBuilder outside + result.length=0 in each loop: +/- 690ms

result = String.Format("{0}{1}{2}{3}{4}", a, b, c, d, e)
+/- 1540ms

so in my opinion, only use string.format to do real formatting :-)
the difference between the first 2 seems strange to me
is this a compiler problem?
oh yes, everything was ran in debug mode in visual studio 2003...

dominique



Relevant Pages

  • Re: Displaying a large amount of data quickly (VB6)
    ... >>> involving a loop of VB code would be too slow. ... but I'd sure be interested to know if that StringBuilder ... Array elements: 25000 ... Array construction: 17 ...
    (microsoft.public.vb.controls)
  • Re: slow reading of eventlog
    ... loop of 1.000.000 concatenations of 5 public string variables in a class ... dim result as new StringBuilder() ...
    (microsoft.public.dotnet.framework.interop)
  • Re: slow reading of eventlog
    ... loop of 1.000.000 concatenations of 5 public string variables in a class ... dim result as new StringBuilder() ...
    (microsoft.public.dotnet.general)
  • string concatenation
    ... loop of 1.000.000 concatenations of 5 public string variables in a class ... dim result as new StringBuilder() ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Stringbuilder in C#
    ... Lovey Dovey, what have you done so far? ... build a test driver that runs a loop 50000 times ... in each loop, concatenate N strings of length L ... with + and with StringBuilder ...
    (microsoft.public.dotnet.framework)