Go to: Synopsis. Return value. Keywords. Related. Flags. Python examples.
profiler([addCategory=string], [allCategories=boolean], [bufferSize=int], [categoryIndex=int], [categoryIndexToName=int], [categoryInfo=string], [categoryName=string], [categoryNameToIndex=string], [categoryRecording=boolean], [clearAllMelInstrumentation=boolean], [colorIndex=int], [eventCPUId=boolean], [eventCategory=boolean], [eventColor=boolean], [eventCount=boolean], [eventDescription=boolean], [eventDuration=boolean], [eventIndex=int], [eventName=boolean], [eventStartTime=boolean], [eventThreadId=boolean], [instrumentMel=boolean], [load=string], [output=string], [procedureDescription=string], [procedureName=string], [removeCategory=string], [reset=boolean], [sampling=boolean], [signalEvent=boolean], [signalMelEvent=boolean])
Note: Strings representing object names and arguments must be separated by commas. This is not depicted in the synopsis.
profiler is NOT undoable, queryable, and NOT editable.
The profiler is used to record timing information from key events within Maya,
as an aid in tuning the performance of scenes, scripts and plug-ins.
User written plug-ins and Python scripts can also generate profiling information
for their own code through the MProfilingScope (C++), MProfilingContextManager
(Python) and MProfiler classes in the API.
This command provides the ability to control the collection of profiling data and
to query information about the recorded events. The recorded information can also
be viewed graphically in the Profiler window.
The buffer size cannot be changed while sampling is active, it will return an error
The reset flag cannot be called while sampling is active, it will return an error.
Any changes to the buffer size will only be applied on start of the next recording.
You can't save and load in the same command, save has priority, load would be ignored.
None
In query mode, return type is based on queried flag.
timing, performance, profiling, optimize
dgtimer
addCategory, allCategories, bufferSize, categoryIndex, categoryIndexToName, categoryInfo, categoryName, categoryNameToIndex, categoryRecording, clearAllMelInstrumentation, colorIndex, eventCPUId, eventCategory, eventColor, eventCount, eventDescription, eventDuration, eventIndex, eventName, eventStartTime, eventThreadId, instrumentMel, load, output, procedureDescription, procedureName, removeCategory, reset, sampling, signalEvent, signalMelEvent
Long name (short name) |
Argument types |
Properties |
addCategory(a)
|
string
|
|
|
Add a new category for the profiler.
Returns the index of the new category.
|
|
allCategories(ac)
|
boolean
|
|
|
Query the names of all categories.
If the categoryInfo flag is set then alternate the name of the category
with the description of the category.
|
|
bufferSize(b)
|
int
|
|
|
Toggled : change the buffer size to fit the specified number of events (requires that sampling is off)
Query : return the current buffer size
The new buffer size will only take effect when next sampling starts.
When the buffer is full, the recording stops.
|
|
categoryIndex(ci)
|
int
|
|
|
Used in conjunction with other flags, to indicate the index of the category.
In query mode, this flag needs a value.
|
|
categoryIndexToName(cin)
|
int
|
|
|
Returns the name of the category with a given index.
In query mode, this flag needs a value.
|
|
categoryInfo(cf)
|
string
|
|
|
When used with the addCategory flag set the description of the added profiler category.
In query mode return the description of the category referenced by either
the categoryIndex or categoryName flags.
In query mode, this flag can accept a value.
|
|
categoryName(cn)
|
string
|
|
|
Used in conjunction with other flags, to indicate the name of the category.
In query mode, this flag needs a value.
|
|
categoryNameToIndex(cni)
|
string
|
|
|
Returns the index of the category with a given name.
In query mode, this flag needs a value.
|
|
categoryRecording(cr)
|
boolean
|
|
|
Toggled : Enable/disable the recording of the category.
Query : return if the recording of the category is On.
Requires the -categoryIndex or -categoryName flag to specify the category to be queried.
|
|
clearAllMelInstrumentation(cam)
|
boolean
|
|
|
Clear all MEL command or procedure instrumentation.
|
|
colorIndex(coi)
|
int
|
|
|
Used with "-instrumentMel true" to specify the color index to show the
profiling result.
|
|
eventCPUId(eci)
|
boolean
|
|
|
Query the CPU ID of the event at the given index.
Requires the -eventIndex flag to specify the event to be queried.
|
|
eventCategory(eca)
|
boolean
|
|
|
Query the category index the event at the given index belongs to.
Requires the -eventIndex flag to specify the event to be queried.
|
|
eventColor(eco)
|
boolean
|
|
|
Query the color of the event at the given index.
Requires the -eventIndex flag to specify the event to be queried.
|
|
eventCount(ec)
|
boolean
|
|
|
Query the number of events in the buffer
|
|
eventDescription(ed)
|
boolean
|
|
|
Query the description of the event at the given index.
Requires the -eventIndex flag to specify the event to be queried.
|
|
eventDuration(edu)
|
boolean
|
|
|
Query the duration of the event at the given index, the time unit is microsecond.
Note that a signal event has a 0 duration.
Requires the -eventIndex flag to specify the event to be queried.
|
|
eventIndex(ei)
|
int
|
|
|
Used usually in conjunction with other flags, to indicate the index of the event.
In query mode, this flag needs a value.
|
|
eventName(en)
|
boolean
|
|
|
Query the name of the event at the given index.
Requires the -eventIndex flag to specify the event to be queried.
|
|
eventStartTime(et)
|
boolean
|
|
|
Query the time of the event at the given index, the time unit is microsecond.
Requires the -eventIndex flag to specify the event to be queried.
|
|
eventThreadId(eti)
|
boolean
|
|
|
Query the thread ID of the event at the given index.
Requires the -eventIndex flag to specify the event to be queried.
|
|
instrumentMel(instrumentMel)
|
boolean
|
|
|
Enable/Diable the instrumentation of a MEL command or procedure.
When the instrumentation is enabled, the execution of MEL command
or procedure can be profiled and shown in the Profiler window.
To enable the instrumentation requires the -procedureName, -colorIndex
and -categoryIndex flags.
To disable the instrumentation requires the -procedureName flag.
|
|
load(l)
|
string
|
|
|
Read the recorded events from the specified file
|
|
output(o)
|
string
|
|
|
Output the recorded events to the specified file
|
|
procedureDescription(pd)
|
string
|
|
|
Used with "-instrumentMel true" to provide a description of the MEL
command or procedure being instrumented.
This description can be viewed in the Profiler Tool window.
|
|
procedureName(pn)
|
string
|
|
|
Used with -instrumentMel to specify the name of the procedure to be
enabled/disabled the instrumentation.
|
|
removeCategory(rc)
|
string
|
|
|
Remove an existing category for the profiler.
Returns the index of the removed category.
|
|
reset(r)
|
boolean
|
|
|
reset the profiler's data (requires that sampling is off)
|
|
sampling(s)
|
boolean
|
|
|
Toggled : Enable/disable the recording of events
Query : return if the recording of events is On.
|
|
signalEvent(sig)
|
boolean
|
|
|
Query if the event at the given index is a signal event.
Requires the -eventIndex flag to specify the event to be queried.
A Signal Event only remembers the start moment and has no knowledge about
duration. It can be used in cases when the user does not care about the
duration but only cares if this event does happen.
|
|
signalMelEvent(sim)
|
boolean
|
|
|
Used with "-instrumentMel true", inform profiler that this instrumented
MEL command or procedure will be taken as a signal event during profiling.
A Signal Event only remembers the start moment and has no knowledge about
duration. It can be used in cases when the user does not care about the
duration but only cares if this event does happen.
|
|
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.
|
import maya.cmds as cmds
# Start profiling
cmds.profiler(sampling = True)
# Wait for events to be profiled
# Stop profiling
cmds.profiler(sampling = False)
# Output the result to a file
cmds.profiler(output = "test.txt")
# Load a recording from a file to the buffer
cmds.profiler(load = "test.txt")
# Reset the tool
cmds.profiler(reset = True)
# Set the profiler's buffer size to fit 5 megaBytes
cmds.profiler(bufferSize = 5)
# Query the profiler's buffer size
cmds.profiler(query = True, bufferSize = True)
# Add a new category
cmds.profiler(addCategory = "Test Category", categoryInfo="Events related to my special test")
# Remove an existing category
cmds.profiler(removeCategory = "Test Category")
# Query the number of categories
cmds.profiler(query = True, categoryCount = True)
# Query the name of the category at the given index
cmds.profiler(query = True, categoryIndexToName = 5)
# Query the info of the category at the given index
cmds.profiler(query = True, categoryIndex = 5, categoryInfo = True)
# Query the index of the category with the given name
cmds.profiler(query = True, categoryNameToIndex = "Maya Qt")
# Query the info of the category with the given name
cmds.profiler(query = True, categoryName = "Maya Qt", categoryInfo = True)
# Query if it is enabled for the recording of the category at the given index
cmds.profiler(query = True, categoryRecording = True, categoryIndex = 5)
# Query if it is enabled for the recording of the category with the given name
cmds.profiler(query = True, categoryRecording = True, categoryName = "Maya Qt")
# Enable/Disable the recording of the category at the given index
cmds.profiler(categoryRecording = False, categoryIndex = 5)
# Query the number of the events in the buffer
cmds.profiler(query = True, eventCount = True)
# Query the time at which the event at the given index start
cmds.profiler(query = True, eventStartTime = True, eventIndex = 100)
# Query the duration of the event at the given index
cmds.profiler(query = True, eventDuration = True, eventIndex = 100)
# Query the name of the event at the given index
cmds.profiler(query = True, eventName = True, eventIndex = 100)
# Query the description of the event at the given index
cmds.profiler(query = True, eventDescription = True, eventIndex = 100)
# Query the category the the event at the given index belongs to
cmds.profiler(query = True, eventCategory = True, eventIndex = 100)
# Query the color of the event at the given index
cmds.profiler(query = True, eventColor = True, eventIndex = 100)
# Query the thread ID of the event at the given index
cmds.profiler(query = True, eventThreadId = True, eventIndex = 100)
# Query the CPU ID of the event at the given index
cmds.profiler(query = True, eventCPUId = True, eventIndex = 100)
# Query if the event at the given index is a signal event
cmds.profiler(query = True, signalEvent = True, eventIndex = 100)