Quantify can collect function time information at different levels of detail, or granularity. As the level of detail increases, so does the cost of collecting the data. By default, Quantify determines the level of detail based on the type of code your compiler emits.
Quantify can collect data at the following levels of granularity:
Collection granularity |
Description |
Function |
Distinguishes counts for each function only |
Basic-block |
Distinguishes counts for each basic block |
Line |
Distinguishes counts for each line |
You can use the -collection-granularity option to control the level of detail at which Quantify collects data. You can specify function, basic-block, or line.
You can use basic-block and line only if debugging information is available; that is, if you compile your application using the -g debugging option.
Quantify tracks the total machine cycles over each function call but does not record any data about machine cycles for basic blocks. This level of data collection incurs the least overhead, requiring about 1 machine cycle for each basic block. This is the detail that is displayed in the Function Detail window.
When you specify -collection-granularity=function, the Annotated Source window is not available.
If debugging information is not present, such as in third-party
libraries and in optimized code, Quantify automatically instruments code
at function granularity.
This setting requires debugging information. Quantify tracks both
the total machine cycles over each function call and the machine cycles
executed in each basic block. Basic block data is used for the line annotations
in the Annotated Source window.
This is the default if debugging information is available. -collection-granularity=line is identical to basic-block granularity, except that when a basic block extends over several lines of source code, Quantify inserts additional counters to record line-by-line counts. This improves readability of the data but at the expense of additional counting at run time.
Counting for basic blocks and lines is substantially slower than counting for function granularity, requiring approximately seven machine cycles per basic block or line counter. This is because Quantify must update both its function counter and each of the basic-block counters as it enters each basic block. Updating the basic-block counters requires updating a counter in memory.
The average cost of each basic block in normal code is 5 to 10 machine cycles. This means that, exclusive of function entry and exit overhead, Quantify's counting insertion in this case slows the function on average by a factor of two. This contrasts with function granularity which slows the same code by only about 20 percent.
To control the granularity of data collection without using the -collection-granularity option, you can:
Recompile your application without using the -g option so Quantify automatically collects data at function granularity.
Use strip -l to remove the line number information from certain files. Quantify then automatically collects data at function granularity.
To speed up data collection in an application compiled for debugging without recompiling the code, use the -force-rebuild option with the -collection-granularity option:
% quantify -force-rebuild \
-collection-granularity=function cc ...