.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Some ideas on speeding up VS during debug

0 REPLIES 0
Reply
Message 1 of 1
JamesMaeding
203 Views, 0 Replies

Some ideas on speeding up VS during debug

So I wrote a parser that takes a string and deserializes it to a tree of values.

It was running very slow during debug.

I did some research and found most people said to open the output window and watch for exceptions.

I did that and saw a lot of system.format exceptions.

So I went to the debug exceptions dialog and checked all items.

That stopped the code on the subroutine making the exceptions.

It was my number test, looked like:

public static bool IsNumber(this string strNumber) {
  try {
    Convert.ToDouble(strNumber);
    return true;
  }
  catch {
    return false;
  }
}

 changed it to:

public static bool IsNumber(this string strNumber) {
  double result;
  return double.TryParse(strNumber, out result);
}

 and no more format exceptions, and debug runs super fast now.

 

The moral of the story is little functions you use a lot should avoid using try - catch if it will be very common to get to the catch potion.

Experienced people will laugh at this experiment, but I've never heard anyone mention exceptions slow debug way down, so may help others.


internal protected virtual unsafe Human() : mostlyHarmless
I'm just here for the Shelties

0 REPLIES 0

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost