DotNetKick.com is an open-source project. Please report any bugs and let us know your great suggestions. Currently running svn revision 620 (rss)

Kick Spy!, Kick Zeitgeist and Kick Widgets

chinhdo Subscribe to this feed
chinhdo
Profile Kicked Submitted Comments Tags Friends Kicked By Friends Submitted By Friends


Comments:

Another potential gotcha when using nullables: Convert.ToInt32(x) returns zero when x==null. Same for ToInt64(), ToSingle(), etc.
posted by chinhdo 5 months, 5 days ago

Thanks for everyone's comments. My example is a little bit on the extreme side but it's to prove a point: that bad/incorrect use of structured exception handling CAN lead to performance problems.

The Programmers Heaven article does say in its conclusion that the performance hit of a try/catch block that never handles an exception is virtually nothing. I totally agree with that.

However, by virtue of having a try/catch block, there is the possibility that it WILL catch and handle an exception :-). I also think that many programmers will read the PH article and come out with the wrong conclusion that they should never worry about performance issues with exception handling.
posted by chinhdo 6 months, 10 days ago

Aaron: Great! Glad I could help :-)
posted by chinhdo 11 months, 3 days ago

I guess I didn't do a good job explaining the loop the first time. I am really comparing the code inside the loop. The for loop is only there to multiply the operation being measured thousands of times so that the final measurement is more accurate. It's the same idea as taking multiple samples and averaging them. If I didn't have the loop, the elapsed time would have been too small to accurately measure. For my test, the "operation" being measured is the concatenation of three string values, including the creation of the StringBuilder object.
posted by chinhdo 11 months, 19 days ago

jamesewelch:

Thanks for the tip about string.concat. I didn't know that string.Concat works differently than using the "+" operator (Concat allocates space for all the strings involved at once and avoids extra copying).

As for moving the creation of the StringBuilder object outside of the loop, that would invalidate the comparison. The purpose of the loop is to measure the entire StringBuilder "operation" multiple times to get a more accurate elapsed time.
posted by chinhdo 11 months, 19 days ago

It would be nice if the article talked about some modern alternatives for FTP.
posted by chinhdo 11 months, 19 days ago
 

Sponsored Link: www.carlist.ie

Search:

Ads via The Lounge