A scary realization, part 2

OK, I just couldn't drop this subject until I'd done some more research. The image below, illustrates what I found:

The application concatenates a bunch of strings, using different methods. Don't bother analyzing the actual individual values, but rather the relation between them:

  • StringBuilder is fastest, most efficient without doubt. NO garbage collection was needed while processing the SAME strings, while all the other methods caused 2001 cleanups of the objects in Generation 0 (ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.NETDEVFX.v20.en/cpref2/html/M_System_GC_CollectionCount_1_804c5d7d.htm)
  • String.Concat uses slightly less memory than &-concatenation, but takes up about the same CPU time.
  • Using the StringBuilder.AppendFormat method, uses almost double the CPU time in comparission to StringBuilder.Append, and even more than using &-concatenation. Furthermore, this was the only method that caused recycling of objects in Generation 1.
  • Using String.Format is the slowest method available.

Comments

Popular posts from this blog

Auto Mapper and Record Types - will they blend?

Unit testing your Azure functions - part 2: Queues and Blobs

Testing WCF services with user credentials and binary endpoints