19

I am attempting to debug a program in VS2010 using a breakpoint with a boolean condition. This particular breakpoint is painfully slow, making my program run hundreds of times slower than without the condition or using a regular unconditioned breakpoint.

My question is, is this a common issue with visual studio, I can't believe the debugger can be this slow? The boolean expression is very simple, it simply says break the program when i == x inside a for loop.

Any help appreciated as it's making debugging very painful.

Thanks Richard

 public static RawNetCalculationResults newCATXLNets(IList<Loss> RawLosses, IList<ReinsuranceProgramme> Programme) //Loss contains the properties Year, EventID, Loss Value { List<Recoveries> NetRawLosses = new List<Recoveries>(RawLosses.Count * Programme.Count); //Initiate list with required capacity //Loop over each element in RawLosses List and do some calculations foreach (var e in RawLosses) { //<----BREAK POINT HERE (e.Year == x) foreach (var layer in Programme.Where(x => x.Type == ReinsuranceType.CATXL)) { 
3
  • It probably isn't the debugger. Can you show us the code? Commented Jan 4, 2013 at 10:43
  • I edited my question with the code. I have one breakpoint on the outer loop. So when the property of an element in the outer loop reaches x (x is an int representing the property Year contained in the List<Loss>). Removing the breakpoint means my code runs very fast (matter of seconds for the entire loop), adding the single breakpoint means it takes around 20minutes. Commented Jan 4, 2013 at 10:51
  • 1
    Found a similar question here: stackoverflow.com/questions/32391419/… Commented Dec 4, 2015 at 9:38

1 Answer 1

33

Yes, conditional breakpoints are slow.

As an alternative, you can use Debug.Assert:

Debug.Assert( i != x ); 

This will cause the assert to fire when i == x and you can debug from there.

Sign up to request clarification or add additional context in comments.

3 Comments

I prefer: if (condition) Debugger.Break();
Works great, I ended up using Debugger.Break for the exact functionality. Somewhat strange the breakpoints themselves are so slow compared to this.
Apparently this have to do with actual physical hardware that's being used for debugging - not something I would have guessed. codeproject.com/Questions/501675/…

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.