Logo

iNVASIVECODE - Blog

  • Archive
  • RSS
  • Ask us anything about iOS
banner
Flags: very useful when debugging with Instruments

There is a very nice feature in Instruments that helps you to point your loupe to a very precise spot in your code.

I am writing an app that process images captured by the camera in real-time. I am using GCD to launch different queues both in asynchronous and synchrous mode and when it is time to debug, it’s a mess. Most of the time I need to know extactly what is doing what and where something is executing.

Using the breakpoints interrupting the execution and analyze the status of your variable, it is not always useful in a multi-threaded environment, because you alter the real flow of your application.

My mind went immediately to Instruments and I found a very cool tool that you can use to know when something is executing.

Performance Session

To use this feature, you need to add to your Xcode project the DTPerfomanceSession.framework and #import into the class you want to analyze.

Now, wherever you need to send a signal to Instruments from your app, you just add this line of code:

DTSendSignalFlag("com.invasivecode.mytracepoints.app.point", DT_POINT_SIGNAL, TRUE);


You can also mark the start and the end of something, inserting these lines at the beginning and at the end of your code chunk:

// Put this line at the beggining
DTSendSignalFlag("com.invasivecode.mytracepoints.app.start", DT_START_SIGNAL, TRUE);

// ... more code here

// put this at the end
DTSendSignalFlag("com.invasivecode.mytracepoints.app.end", DT_END_SIGNAL, TRUE);


Done that, you can now lunch your Instruments, select the tool or the set of tools (Allocation, Profiler, etc.) you need and start to analyze your code. When the execution hits the above macros, Instruments will show a flag in the timeline as illustrated here:



You can also click on each flag and it will provide you with some detail information:



You can imagine how this is useful during the debugging and especially in a multi-threaded environment, where lots of things are happening in parallel. If you combine this with small tricks like putting a short sleep in your code, you can really get very close to each bit of execution.

Geppy
Pop-upView Separately

Flags: very useful when debugging with Instruments

There is a very nice feature in Instruments that helps you to point your loupe to a very precise spot in your code.

I am writing an app that process images captured by the camera in real-time. I am using GCD to launch different queues both in asynchronous and synchrous mode and when it is time to debug, it’s a mess. Most of the time I need to know extactly what is doing what and where something is executing. Using the breakpoints interrupting the execution and analyze the status of your variable, it is not always useful in a multi-threaded environment, because you alter the real flow of your application.

My mind went immediately to Instruments and I found a very cool tool that you can use to know when something is executing.

Performance Session

To use this feature, you need to add to your Xcode project the DTPerfomanceSession.framework and #import into the class you want to analyze.

Now, wherever you need to send a signal to Instruments from your app, you just add this line of code:

DTSendSignalFlag("com.invasivecode.mytracepoints.app.point", DT_POINT_SIGNAL, TRUE);

You can also mark the start and the end of something, inserting these lines at the beginning and at the end of your code chunk:

// Put this line at the beggining
DTSendSignalFlag("com.invasivecode.mytracepoints.app.start", DT_START_SIGNAL, TRUE);

// ... more code here

// put this at the end
DTSendSignalFlag("com.invasivecode.mytracepoints.app.end", DT_END_SIGNAL, TRUE);

Done that, you can now lunch your Instruments, select the tool or the set of tools (Allocation, Profiler, etc.) you need and start to analyze your code. When the execution hits the above macros, Instruments will show a flag in the timeline as illustrated here:

Instruments flags

You can also click on each flag and it will provide you with some detail information:

Flag details

You can imagine how this is useful during the debugging and especially in a multi-threaded environment, where lots of things are happening in parallel. If you combine this with small tricks like putting a short sleep in your code, you can really get very close to each bit of execution.

Geppy

    • #instruments
    • #debug
    • #xcode
    • #sdk
    • #ios
    • #apple
    • #iphone
    • #ipad
    • #mac
    • #os x
  • 1 year ago
  • 7
  • Permalink
  • Share
    Tweet

7 Notes/ Hide

  1. do-nothing reblogged this from invasivecode
  2. i0sdev reblogged this from invasivecode
  3. scottdensmore reblogged this from invasivecode
  4. martinpilch reblogged this from invasivecode
  5. geppyp reblogged this from invasivecode
  6. amirsaam likes this
  7. andthirdly likes this
  8. invasivecode posted this
← Previous • Next →
iNVASIVECODE is a design and development enterprise with the passion for engineering beautiful iOS and OS X apps.

iNVASIVECODE offers 5-days iOS training classes for professional developers and on-site technical consulting.

Pages

  • HOME
  • iOS TRAINING CLASSES
  • TUTORIAL ON CORE TEXT
  • QUARTZ CRASH COURSE
  • CONTACT US

More about us

  • @invasivecode on Twitter
  • Google
  • Linkedin Profile

loading tweets…

I Dig These Posts

See more →
  • RSS
  • Random
  • Archive
  • Ask us anything about iOS
  • Mobile

Copyright ©2008-2013 iNVASIVECODE, Inc. Effector Theme by Carlo Franco.

Powered by Tumblr