The Visual Profiler allows the user to profile function calls. This tool works similar to the visual inspector, as several charts are provided for visualizing the data:
- Time Tree
- Space Tree
- TMC Tree
The profiler measures runtime and memory usage for the function calls in a given functions call stack. The Visual Profiler then uses the interface for the Visual Inspector to display those results.
Opening the Profiler
Similar to the Visual Inspector, the profiler can be opened by picking Tools, then Visual Profiler from the main view in Developer.
Opening on an expression
The Visual Profiler can also be invoked from Developer by selecting any q expression that invokes a function and performing one of the following operations:
- Right-click and pick Profile from the context menu
- Press Meta+Alt+P on the keyboard as a shortcut
The Developer IDE will then profile the q expression that had been selected, and will present a default Table view of the Profiler result.
Entering queries into the Profiler
Similar to the Visual Inspector, you can enter q queries directly into the query input line.
The Profiler reports four types of measurements of function performance.
The runtime of the function calls as a timestamp.
The memory used the function calls in bytes.
The runtime of each function call minus any time spent in the child functions as a timestamp. Thus, it reports the time spent exclusively in a given function.
The memory used by each function call minus the memory used by the most memory intensive child function, in bytes. Given that memory may be reused by child functions, this measure reports the maximum possible memory that was used exclusively by the given function.
There are five settings for controlling the behaviour of the Profiler.
|Log Anonymous Functions||It is possible to profile lambda functions within another function using this setting.|
|Include Functions||The profiler attempts to automatically find all the functions in a call stack. This will include any that may be missed.|
|Include Contexts||This will include all functions in any contexts that may be missed by the Profiles.|
|Ignore Functions||This will ignore any functions that the user does not want to profile.|
|Ignore Contexts||This will ignore all functions in any contexts that the user does not want to profile.|
For the Include Functions, Include Contexts, Ignore Functions, and Ignore Contexts settings, each function name should be typed into the input, separated by spaces. Include on the name of the function(s) by omitting the tick character that preceeds q symbols.
In the below image, f3 is marked as a function to include while profiling, while f4 and f6 are marked as functions to ignore. Note that f3 does not need to be in the Include Functions list as it will be automatically found by the Profiles. See the (Profiler Function Reference)[../app/qdoc/profiler.html] for more details.
To use the updated settings the expression must be re-executed. Do to so, click on the expression in the query input line and click Enter.
Five chart types are available in the Visual Profiler. Each available chart is outlined here along with a description of the attributes associated with each.
See the Visual Inspector for more details about viewing and accessing plots.
The default chart in the Visual Profiler is a conventional table. This table works the same as the table chart for the Visual Inspector.
The table result from the Visual Profiler always has the same columns to report the Profiles results.
The name of the function is reported in the name column, and the number of times that function was run is executed is reported in the calls column.
The rest of the columns are aggregations of the four Profiles measurements discussed above.
| Profiler measurement | columns | ----------------------------------------------------------------| | Time | totalTime, avgTime, maxTime, minTime | | Space | avgSpace, maxSpace, minSpace | | TMC | totalTMC, avgTMC, maxTMC, minTMC | | SMC | avgSMC, maxSMC, minSMC |
As can be seen, the runtime measurements (Time and TMC) report the total, average, max, and minimum runtimes for the function calls, while the memory measurements (Space and SMC) only report the average, max, and minimum memory consumption.
The Time Tree shows the call tree for the function, reporting the runtime of each function call as the colour and size of each node.
The TMC Tree shows the call tree for the function, reporting the TMC of each function call as the colour and size of each node.
The Space Tree shows the call tree for the function, reporting the memory used by each function call as the colour and size of each node.
The Timeline shows a timeline of each function call, with boxes weighted by the memory used for each function.