Retired Document
Important: This document may not represent best practices for current development. Links to downloads and other resources may no longer be valid.
Overview
After completing the first stages of program development, like design and debugging, you can use performance tools such as Saturn to help optimize your program. Saturn helps you understand your program’s function-calling structure and how much time was spent in each function. Saturn consists of two parts: a graphical front-end and a dynamic library back-end. The Saturn back-end library leverages the instrumentation infrastructure in gcc
to generate an output file that summarizes how much time your program spends in various functions. The Saturn front-end can then read this file and present a representation of the function calling patterns and a function tree view.
UNIX implementations typically support a notion of compiler driven function instrumentation by specifying compiler flags to request instrumentation. The compiler supplied by Apple responds to two different command line options:
-pg
— This causes the insertion of call graph profile data generating code into every function prologue during compilation. Each execution of your program produces agmon.out
file. The standard tool for reviewing these files is thegprof
command-line tool, but Saturn’s front end can display the same information in a graphical manner on PowerPC-based Macs only.-finstrument-functions
— This causes the insertion of separate user-defined instrumentation routines for each function prologue and epilogue. It incurs somewhat more overhead than-pg
, but allows you to record a selection of custom data items in addition to basic timing. This option works with both PowerPC and Intel-based Macs.
Saturn allows you to visualize the data in two ways: a traditional call-tree view and a graphical call-stack timeline. Using this information, you can eliminate expensive calling behavior (for example, deep call stacks which do not last long) as well as understand which functions take up the greatest portion of execution time.
Copyright © 2012 Apple Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2012-07-23