0

Some users are complaining that Autodesk Maya is taking a long time to start - this is before loading a scene. I'd like to take an objective measure of the wall-clock startup time, and log it, so that we can analyze the situation.

The logic to perform a wall-clock measure is trivial. My question is, where can I hook the logic in? I want to start the clock as soon as possible, and only stop it once all userSetup.py plugins and shelf tools are loaded, and the GUI is visible.

If possible, I'd also like to note if Maya was started with a blank scene, or opened with a scene file.

lofidevops
  • 15,528
  • 14
  • 79
  • 119
  • the answer to https://stackoverflow.com/questions/29150421/how-to-measure-the-time-of-a-maya-script looks promising (just need to call it once everything is loaded) – lofidevops Mar 22 '16 at 12:09

1 Answers1

3

Warning: Untested

in your userSetup.py:

import maya.mel
import maya.utils

def print_time_since_startup():
    elapsed = maya.mel.eval("timerX()")
    cmds.warning ("maya startup time: %s" % elapsed)

maya.utils.executeDeferred(print_time_since_startup)

That should fire the timerX() after mayas first idle state. 2016 seems to do deferred loading of plugins so things may pop up after that. If this is insufficient check out the documentation for cmds.scriptJobj and see if any of the conditions listed for the -ct flag do what you need

theodox
  • 12,028
  • 3
  • 23
  • 36
  • What if, you launch maya trough a system call in a external application and then open a socket up (or print to console?). Then in user Setup eval deferred a communication to that socket. This would then more accurately account for the time of startup before userSetup. mel is executed, which actually happens quite late in the init process. – joojaa Mar 23 '16 at 07:58
  • AFAIK TimerX is 'time since maya was initialized'. The executeDeferred should force it to evaluate on Maya's first idle event, which would be the earliest moment when Maya was interactive. Seems close enough for horseshoes – theodox Mar 23 '16 at 15:55
  • In my experience thats not true in newest mayas. – joojaa Mar 23 '16 at 16:02
  • great tip! based on your answer I also found evalDeferred(lowestPriority=True) -- rudimentary testing (in 2016) suggests it gets called later than execute deferred -- any thoughts? – lofidevops Mar 24 '16 at 10:16
  • That makes sense, might account for the background loads – theodox Mar 24 '16 at 14:03