script for measuring framerates?

34 views
Skip to first unread message

Ravi Jagannadhan

unread,
Nov 11, 2015, 11:52:12 PM11/11/15
to python_in...@googlegroups.com
Hi all, does anyone have any scripts handy for measuring frame rates (one that's not in the GUI)?

Thank you for your time,
Ravi
--
Where we have strong emotions, we're liable to fool ourselves - Carl Sagan.

Marcus Ottosson

unread,
Nov 12, 2015, 3:10:51 AM11/12/15
to python_in...@googlegroups.com
Frame rates of what?

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CADHeb2Z8NXCQVc79PODDY80qj6Szp27NN%2BhZ_8%3Dt0SYiv1xBLw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.



--
Marcus Ottosson
konstr...@gmail.com

Ravi Jagannadhan

unread,
Nov 12, 2015, 8:44:00 AM11/12/15
to python_in...@googlegroups.com
Sorry, playback in Maya.

"There are no dumb questions" - Carl Sagan.

Marcus Ottosson

unread,
Nov 13, 2015, 2:58:13 AM11/13/15
to python_in...@googlegroups.com

Here is one way of doing it.

import time
from maya import OpenMaya as om

time.__previous = time.time()
def callback(*args, **kwargs):
    current = time.time()
    fps = 1 / (current - time.__previous)
    time.__previous = current
    print("%.1f" % fps)  # Show only 1 decimal

job = om.MDGMessage.addTimeChangeCallback(callback, 'transform')

The additions to the time module were to maintain a reference to the previous_time variable, which apparently gets lost in a callback like this.

Output.

28.6
22.2
27.8
22.2
28.6
22.7
27.0
23.3
28.6
22.2
28.6

Alternatively, you could also use a script node, or an expression. Both of which are capable of listening in on timeChanged.



For more options, visit https://groups.google.com/d/optout.



--
Marcus Ottosson
konstr...@gmail.com

Reply all
Reply to author
Forward
0 new messages