Re: why are conditional breakpoints SO SLOW?
Re: why are conditional breakpoints SO SLOW?
- Subject: Re: why are conditional breakpoints SO SLOW?
- From: Roland King <email@hidden>
- Date: Wed, 19 Mar 2014 06:36:18 +0800
No it isn't happening 1.5 million times. If it were I'd not have asked about it. The data is being read on average 200 bytes at a time and incrementing offset by that much, so 1,600,000/200 is 8000 times round the loop. I timed it, it took 9.5 minutes to run, 10 for round numbers, that's 600 seconds, so each test is taking just over 1/15 second. 1/15 of a second is a very long time on a modern processor to work out this is a conditional breakpoint and test a == b.
The entire file gets read, and checked, and chopped up into 8000 chunks in less time than that.
Yes it's obvious I can compile an if into it. Recently however I watched, again, the WWDC 2013 video about debugging in Xcode which was focused mostly on how you can use breakpoint actions and conditions NOT to have to litter your code with ifs and NSLog()s you have to take out later and I've been trying to use them. The breakpoint actions are quite good, but the performance hit from the conditionals, at least this one, makes it pretty useless.
On 18 Mar, 2014, at 11:43 pm, "Dallman, John" <email@hidden> wrote:
>> If I turn off that one conditional breakpoint, the code finishes (with the error)
>> instantly. How can a trivial conditional breakpoint be this incredibly slow?
>
> Sadly, that is quite easy. The way conditional breakpoints work is that the breakpoint
> instruction is put into the code, and the app starts. Each time the breakpoint is hit,
> it is looked up, found to be a conditional breakpoint, expression is evaluated, and
> found to be false, the count is incremented, the replaced instruction is run, and then
> the app is resumed. This is happening 1.5 million times.
>
> You can do this much more efficiently by changing your code a little: put something
> like this in the code for the loop over the bytes:
>
> if( offset == 1512800)
> {
> ((write some code to print something in a way suitable to your app))
> }
>
> then set your breakpoint on the code in the block. This will run much faster, because
> it does the counting in the app code, without having to trap into the debugger and
> do interpreted stuff there.
>
> --
> John Dallman
>
> -----------------
> Siemens Industry Software Limited is a limited company registered in England and Wales.
> Registered number: 3476850.
> Registered office: Faraday House, Sir William Siemens Square, Frimley, Surrey, GU16 8QD.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden