July 2007 Archives

Performance #6: Reading Directly Into the Parser

July 23, 2007

This article is part of the series An Exercise in Performance Tuning in C#.Net.

As I look at the code I now have, I wonder if the fileLines variable is an unnecessary intermediate step. Can I rewrite so that stream.ReadLine() is passed directly into the parsing? If I do so, I’ll be leaving the file open longer, but since no other application should be attempting to access the file, I’m okay with that. This means moving the open file command into MyClass.ProcessFile().

Performance #5: File Buffering

July 19, 2007

This article is part of the series An Exercise in Performance Tuning in C#.Net.

It's time to stop ignoring the 800 pound gorilla in the room: System.String. Scrolling all the way over in the Allocation Graph, it is clear that Strings take up most of the memory, and it seems logical that most of that comes from the input file.

filebuffer1.jpg

Threading Links

July 18, 2007

I don't often have cause to use threading. In fact, I've found that it sometimes gums up the works (perhaps because I don't understand it well enough?) — slows things down. But when I do want to do some threading in C#, here are a few pages I find helpful in reminding myself how to perform various functions:

Visual Studio Says: "Failed to create component"

July 17, 2007

Problem: "Failed to create component" error pops up when dragging a custom Windows Forms control from the Toolbox onto a form. Offending line: foreach (Attribute att in Assembly.GetEntryAssembly().GetCustomAttributes(true)).

Background: I have started building a custom DLL containing items for re-use between different Windows Forms projects. An obvious candidate is an About window. I created this as a custom control in the DLL project; the control contains a textbox, which I want to fill with the application name, the version, copyright information, and company name. All of this is to come from the AssemblyInfo.cs file, using System.Reflection where necessary:

Performance #4: Consolidate Object Creation from Database

July 14, 2007

This article is part of the series An Exercise in Performance Tuning in C#.Net.

At this point I did not re-run the profiler but continued investigating memory allocation. Here’s an interesting looking result:

calc1.jpg

Microsoft says: use Netscape

July 10, 2007

Here's a first: in "Microsoft Office Live Meeting" I got a warning message telling me that IE 7 is too new, try IE 6 or Netscape 7 instead. The irony is thick. You have to see it to believe (below).

Rethrowing Exceptions Is a Dangerous Business

July 9, 2007

Problem: in Visual Studio's debugger, you've landed on an Exception statement. You look at the stack trace but it just points back to a custom exception class you've created. But you know that code is good, it can't be throwing the error. What's going on here?

Solution: this is an easy mistake to make. I've run it across it in code from a number of people, and recall making the mistake myself at one point. The problem is most likely due to nested throws to a new custom exception.

Collection Performance Comparisons

July 6, 2007

This is not part of my series on performance tuning a specific app.

Problem: I have a Registry class in which I want to place a generic collection of objects. In this way I can add new items to the registry on the fly (i.e. from a user application), without having to recompile the library containing the the class. What is my best option, in terms of performance, for a .Net 2.0 collection to hold my mixed-bag of objects? I'll be referring to these with a string name.

Performance #3: CLR Profiler

July 5, 2007

This article is part of the series An Exercise in Performance Tuning in C#.Net.

Where else could I improve performance? I thought I should inspect the memory usage and garbage collection. For that I found a great little tool from Microsoft, the CLR Profiler, which I found through the MSDN Patterns & Practices series of guides on application performance and scalability. The specific article that I found most helpful was How To: Use CLR Profiler.

About this Archive

This page is an archive of entries from July 2007 listed from newest to oldest.

June 2007 is the previous archive.

August 2007 is the next archive.

Find recent content on the main index or look in the archives to find all content.

Categories

Pages

OpenID accepted here Learn more about OpenID
Powered by Movable Type 5.12