Rcjp's Weblog

July 3, 2005

ACCU Review

Filed under: c — rcjp @ 3:07 pm

Maximizing .NET Performance by Nick Wienholt

(1-59059-141-0) Apress, 280pp @£32.00
(appeared in CVu Aug 2005 Vol 17 No 4)

The experienced C/C++ coder usually has a reasonable idea of the cost of using certain instructions and can visualise the generated assembler. However, with a .NET language the translation of instructions into Microsoft Intermediate Language (MSIL) calling into the Common Language Runtime (CLR) adds another layer between your code and the machine. Add in garbage collection and performance penalties are not obvious without investigation. This analysis is the subject of the book.

Assuming no previous experience of performance testing, it begins with basic definitions of white box/black box testing, profiling etc. itemising the factors to consider when benchmarking code. Most of this is common sense provided you have a healthy sceptical nature for performance figures. Described in the appendix, and available on the publisher’s website, is the benchmarking testbed used throughout the book.

If you find yourself wondering how to balance execution speed against convenient code use, then this book will prove invaluable in helping you make an informed decision avoiding disappointing performance. If your completed programs are too slow, it is usually too late to refactor code, changing deep internal structures: hence, there is only one short chapter at the end of the book devoted to solving existing performance problems.

It is not only the choice of data structure that need investigating; the .NET framework provides alternative solutions for many problems e.g. when considering thread safety, there are several methods for synchronisation to choose from. There are chapters devoted to studying the comparative merits of strings manipulations, collections, garbage collection, exceptions, IO and remoting amongst others. Throughout the book are references to numbered tests backing up the authors conclusions. Optimising is a notoriously controversial topic with more opinions than facts and I find it extremely refreshing to see frequent referenced tests. It also encourages you to investigate other performance characteristics of the .NET Framework using the provided testbed.

Most of the example code is in C# or VB but C++ is included with sections to cover the effects of converting unmanaged to managed code. There is also an interesting comparison of how all three languages take advantage of the CLR. The book is well written, perhaps occasionally a little verbose, but it is analytical without being dry, clearly typeset, includes plenty of valuable information and can be read cover-to-cover or used as a reference. In short, you should read this book before writing performance dependent .NET code. Recommended.

Advertisements

Leave a Comment »

No comments yet.

RSS feed for comments on this post.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: