Am using a For Loop like following:
for (int i = 0; i < 1000; i++)
{
int mod = i % 1795;
//Do some operations here
}
it works fine, but when i put a break point and apply condition as mod=150
then it slow down the execution. why this is happening? what is actually happening when i add such conditional breakpoints?
A conditional breakpoint is not something supported by the hardware; processors only support unconditional breakpoints. What's going on is that when you create a conditional breakpoint, the debugger inserts an unconditional breakpoint into your code. When the unconditional breakpoint is hit, the debugger evaluates your condition, and if it fails just resumes execution. Since each pass by the breakpoint location now requires stopping and involving the debugger, the code runs much more slowly.
Depending on how often that code executes and how long your code takes to build it's often faster to just add an
if (your condition)
{
System.Diagnostics.Debugger.Break();
}
or similar and just rebuild your app.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With