Go to: Synopsis. Flags. Return value. Keywords. Related. Python examples.

Synopsis

dgtimer([combineType=boolean], [hierarchy=boolean], [maxDisplay=int], [name=string], [noHeader=boolean], [outputFile=string], [reset=boolean], [returnCode=string], [threshold=double], [timerOff=boolean], [timerOn=boolean], [type=string])

Note: Strings representing object names and arguments must be separated by commas. This is not depicted in the synopsis.

dgtimer is NOT undoable, queryable, and NOT editable.

This command measures dependency graph node performance by managing timers on a per-node basis. Logically, each DG node has a timer associated with it which records the amount of real time spent in computation on its plugs. The time measurement includes the cost of copying data to the node on behalf of computation, MEL commands executed by an expression contained in an expression node, and includes any wait time such as when a fileTexture node loads an image file from disk. However, certain DG operations are not reported (basically anything which does not take place during computePlug), such as dirty propgation and curve evaluation time.

The timing mechanism which is used by dgtimer is built into the DG itself, thus ALL depend nodes can be timed and there is no need for programmers writing plug-ins using the OpenMaya API to add any special code in order for their nodes to be timed -- its all handled transparently.

The dgtimer command allows node timers to be turned on, off, reset to zero, and have their current value displayed, and these operations can be performed globally on all nodes or on a specific set of nodes defined by name, type or parentage. Note that all timer measurements are computed in "real time" (the same time measurement you get from a wristwatch) as opposed to "CPU time" (which only measures time when the processor is executing your code). All times are displayed in seconds.

In addition to the per-node information, there is also global information which is collected. These values are reset whenever a global timer reset occurs (i.e. dgtimer -reset; is specified). The global values which are measured are:

The per-node information which is displayed is as follows:

Use the -query flag to display the current timer values on a node,
use -on to turn on timing,
use -off to turn off timing,
and -reset to reset timers to zero.

Flags

combineType, hierarchy, maxDisplay, name, noHeader, outputFile, reset, returnCode, threshold, timerOff, timerOn, type
Long name (short name) [argument types] Properties
combineType(ct) boolean query
Causes all nodes of the same type (e.g. animCurveTA) to be combined in the output display.

In query mode, this flag needs a value.

hierarchy(h) boolean createquery
Used to specify that a hierarchy of the dependency graph be affected, thus "-reset -hierarchy -name ball" will reset the timers on the node named "ball" and all of its descendents in the dependency graph.

In query mode, this flag needs a value.

maxDisplay(m) int query
Truncates the display so that only the most expenive "n" entries are printed in the output display.

In query mode, this flag needs a value.

name(n) string createquery
Used in conjunction with -reset or -query to specify the name of the node to reset or print timer values for. When querying a single timer, only a single line of output is generated (i.e. the global timers and header information is omitted). Note that one can force output to the script editor window via the "-outputFile MEL" option to make it easy to grab the values in a MEL script. Note: the -name and -type flag cannot be used together.

In query mode, this flag needs a value.

noHeader(nh) boolean createquery
Used in conjunction with -query to prevent any header or footer information from being printed. All that will be output is the per-node timing data. This option makes it easier to parse the output such as when you output the query to a file on disk using the -outputFile option.

In query mode, this flag needs a value.

timerOff(off) boolean create
Turns off node timing. By default, the timers on all nodes are turned off, but if specified with the -name or -type flags, only the timers on specified nodes are turned off. If the timers on all nodes become turned off, then global timing is also turned off as well.
timerOn(on) boolean create
Turns on node timing. By default, the timers on all nodes are turned on, but if specified with the -name or -type flags, only the timers on specified nodes are turned on. The global timers are also turned on by this command. Note that turning on timing does NOT reset the timers to zero. Use the -reset flag to reset the timers. The idea for NOT resetting the timers is to allow the user to arbitrarily turn timing on and off and continue to add to the existing timer values.
returnCode(rc) string query
Used in conjunction with the -query flag to specify the return code for the command. The return code is the value returned by the dgtimer command after it is invoked. The values that can be returned are as follows:

  • "count" for the sum of the "Count" column. This is the total number of times all the compute() methods have been invoked since the last timer reset.
  • "nodecount" for the total number of nodes in Maya.
  • "selftime" for the sum of the "Self time" column. This is the total time spent in all the compute() methods for all nodes since the last timer reset. This is also the default return code for the dgtimer command.
The returnCode feature is very handy for checking various aspects of Maya. For example, if one wants an easy way to determine the total number of nodes, without outputting a voluminous amount of other dgtimer data, try:

dgtimer -rc "nodecount" -threshold 100 -noHeader -query; This returns the total number of nodes defined in Maya.

In query mode, this flag needs a value.

outputFile(o) string query
Used in conjunction with the -query flag to cause output to be directed to an output file. By default, output is to stdout, but can be redirected e.g. -outputFile "/home/virginia/timing/dgtrace.txt". This makes it handy to load the data into an external application such as a spreadsheet program. To force output to the script editor, use "-outputFile MEL" which makes it easy to grab the values from within a MEL script.

In query mode, this flag needs a value.

reset(r) boolean create
Resets the node timers to zero. By default, the timers on all nodes as well as the global timers are reset, but if specified with the -name or -type flags, only the timers on specified nodes are reset.
threshold(th) double query
Truncates the display once the percentage of total execution time falls below the threshold value.

In query mode, this flag needs a value.

type(t) string createquery
Used in conjunction with -reset or -query to specify the type of the node(s) (e.g. animCurveTA) to reset or print timer values for. When querying, use of the -combineType flag will cause all nodes of the same type to be combined into one entry, and only one line of output is generated (i.e. the global timers and header information is omitted). Note that one can force output to the script editor window via the "-outputFile MEL" option to make it easy to grab the values in a MEL script. Note: the -name and -type flag cannot be used together.

In query mode, this flag needs a value.


Flag can appear in Create mode of command Flag can appear in Edit mode of command
Flag can appear in Query mode of command Flag can have multiple arguments, passed either as a tuple or a list.

Return value


double: total DG evaluation time in seconds of wall-clock time.

Keywords

dependency, graph, optimize, performance

Related

dbtrace, dgcount, dgdebug, dgfootprint, objstats, timer

Python examples

import maya.cmds as cmds

# Turns on node timing and resets the timers.
cmds.dgtimer( on=True )
# Turns off node timing. Note that this does not reset the
# timers.
cmds.dgtimer( off=True )
# Prints the current timer values to the default (stdout).
cmds.dgtimer( query=True )
# To reset the timers:
cmds.dgtimer( reset=True )
# Turn on node timing and reset the timer values to zero.
# Then, playback the scene, turn off timing and dump to a file.
# Turn on timing without resetting the timers, and repeat.
cmds.dgtimer( on=True, reset=True )
cmds.play( wait=True )
cmds.dgtimer( off=True )
cmds.dgtimer( outputFile='/home/virginia/timing/dgtrace_once.txt', query=True )
cmds.dgtimer( on=True )
cmds.play( wait=True )
cmds.dgtimer( off=True )
cmds.dgtimer( outputFile='/home/virginia/timing/dgtrace_twice.txt', query=True )