I've create a profiling profile in Instruments.app from the blank template, and I'd like to use it to profile a command line program. The problem is that the program exits rather quickly (in a matter of seconds), which means I can't simply select it in the Instruments process dropdown to attach to it while it's running.
Is there a way to use an existing Instruments profile while launching a command line application, and start collecting data immediately, instead of attaching to a running process?
I do not have an Xcode project, or even the source code. I simply want to attach to an existing application right after it starts up. If it is relevant I'm using Instruments 6.1 on OS X Yosemite.
If there was a way to somehow start the profiling directly from the command line, and not from the Instruments GUI, that would be even better, but I'm not sure if such thing is possible.
Instruments will be installed to your system drive, in /Developer/Applications/ -- run it from there, or from the Xcode application menu item select Open Developer Tool->Instruments (in newer versions of Xcode). When Instruments first starts, you must make a template choice.
Instrumenting AllocationsPress Command-I in Xcode, select Allocations from the list and press Choose. After a moment, you'll see the Allocations instrument. It should look familiar because it looks a lot like Time Profiler. Click the record button in the top-left corner to run the app.
Instruments is a performance-analysis and testing tool for iOS, iPadOS, watchOS, tvOS, and macOS apps.
Build a command line executable with debug symbols enabled:
gcc -Wall -g -O3 profile_me.c -o profile_me
Launch Instruments, select Time Profiler
.
Choose target...
from the hierarchical menu to the right.Choose target
dialog, navigate to your executable and select it. Also set any command line options, environment variables, and the working directory, if needed.Choose
button to save the target options and dismiss the Choose target
dialog - you should now see the target name to the right of you machine name in the top left corner of the Time Profiler window: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