Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Solutions or workaound for Visual Studio conditional breakpoint slowness

I'm using a conditional breakpoint to determine when a C# DateTime variable is greater than a certain time. This breakpoint will be checked approximately 50,000 times in a run.

my conditional breakpoint looks like:

quote.Time > new DateTime(2014,2,4,3,59,0)

Without this conditional break point my test run takes about 15 seconds. With the conditional breakpoint it takes 45 minutes.

Is there anything I can do to help speed this without modifying the code I'm debugging to add an assert or conditional?

Is there anyway to make it calculate the DateTime variable only once? Or is this more of an architectural issue with how conditional breakpoints are implemented in the IDE?

like image 728
chollida Avatar asked Feb 04 '14 16:02

chollida


People also ask

What are the ways you can continue debugging from a breakpoint in Visual Studio?

In most languages supported by Visual Studio, you can edit your code in the middle of a debugging session and continue debugging. To use this feature, click into your code with your cursor while paused in the debugger, make edits, and press F5, F10, or F11 to continue debugging.

How do I temporarily disable breakpoints in Visual Studio?

You can disable all breakpoints in one of the following ways: On the Debug menu, click Disable All Breakpoints. On the toolbar of the Breakpoints window, click the Disable All Breakpoints button.

Why does Visual Studio not stop at breakpoint?

This problem occurs because ASP.NET debugging isn't enabled on the application.

How do I set breakpoint conditions in Visual Studio?

Right-click the breakpoint symbol and select Conditions (or press Alt + F9, C). Or hover over the breakpoint symbol, select the Settings icon, and then select Conditions in the Breakpoint Settings window.


2 Answers

why don't you stop using a conditional break point and change the code until you have debugged it. so the code would become something like:

int dummyx = 0;
if (quote.Time > new DateTime (2014,2,4,3,59,0 )
{

dummyx++; // put normal break point here!

}

This will run much faster.

like image 53
AnthonyLambert Avatar answered Sep 27 '22 22:09

AnthonyLambert


Just for debugging purposes I'd say create a new if-statement and a dummy variable (like int i = 0;) and set the breakpoint on that line. Then just step into / step through the rest of the code.. Just for testing, you can always just remove those 1-2 lines of code after testing.

The if-statement (logically) containing: if (quote.Time > new DateTime(2014,2,4,3,59,0)) { int i=0; }

like image 21
Leon Avatar answered Sep 27 '22 22:09

Leon