Check time taken to open a file

36 views
Skip to first unread message

likage

unread,
Jul 7, 2015, 11:00:37 PM7/7/15
to python_in...@googlegroups.com
Hi all,

I suppose this question of mine can only be done by scripting...
Was wondering if there are any ways to check the time - how long Maya takes to open a file?


Justin Israel

unread,
Jul 7, 2015, 11:12:35 PM7/7/15
to python_in...@googlegroups.com
Do you want to time a cmds.file() operation that you are running? If so, just time it yourself:

import time
start = time.time()
cmds.file(...)
end = time.time()-start

If you want a hook into when a standard file operation is happening, outside of your control, then you can use MSceneMessage to hook into the before/after callbacks: 

--
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/aaf774c1-7e21-433b-99e6-0a7605f00445%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Kurian O.S

unread,
Jul 7, 2015, 11:12:52 PM7/7/15
to python_in...@googlegroups.com
import time
import maya.cmds as cmds
curTime = time.time()
fileToOpn = "/some/fld/somefile.mb"
cmds.file(fileToOpn, o=True,f=True)
print "%s to %s seconds" % (fileToOpn, time.time() - curTime)

This will show in seconds

--
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/aaf774c1-7e21-433b-99e6-0a7605f00445%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
--:: Kurian ::--

likage

unread,
Jul 7, 2015, 11:55:29 PM7/7/15
to python_in...@googlegroups.com
Thanks guys, that is what I am looking for :D

Will take a look into Maya API though it may take me a while to digest it since I am not at all familiar with it.

I have a question though.

While using the 2 methods as suggested by Justin and Kurlan, the output results that I have obtained from both methods are slightly different.
Justin's method gave me 44.0617549419 while Kurlan's method gave me 44.7263860703

Though the difference is very minor, was wondering if anyone could tell me why is there a 0.7 gap? I am pretty curious in it seeing that the coding for both method is almost the same...


Kurian O.S

unread,
Jul 7, 2015, 11:59:52 PM7/7/15
to python_in...@googlegroups.com
There will be slight difference always based on the cpu usage, even like you have a vlc player playing can make a huge difference in the results :). 

--
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.

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



--
--:: Kurian ::--

Kurian O.S

unread,
Jul 8, 2015, 12:00:29 AM7/8/15
to python_in...@googlegroups.com
And remember Justin is always right :D
--
--:: Kurian ::--

likage

unread,
Jul 8, 2015, 12:05:09 AM7/8/15
to python_in...@googlegroups.com
I see, will keep a lookout again the next time when I tried to open another big file.
Pretty sure that I am opening the file (each methods) in about the same environment.

Aye' Sir - on your latest reply XD



On Wednesday, July 8, 2015 at 12:00:29 PM UTC+8, Kurian wrote:
And remember Justin is always right :D
On Tue, Jul 7, 2015 at 8:59 PM, Kurian O.S <kuri...@gmail.com> wrote:
There will be slight difference always based on the cpu usage, even like you have a vlc player playing can make a huge difference in the results :). 
On Tue, Jul 7, 2015 at 8:55 PM, likage <dissid...@gmail.com> wrote:
Thanks guys, that is what I am looking for :D

Will take a look into Maya API though it may take me a while to digest it since I am not at all familiar with it.

I have a question though.

While using the 2 methods as suggested by Justin and Kurlan, the output results that I have obtained from both methods are slightly different.
Justin's method gave me 44.0617549419 while Kurlan's method gave me 44.7263860703

Though the difference is very minor, was wondering if anyone could tell me why is there a 0.7 gap? I am pretty curious in it seeing that the coding for both method is almost the same...


--
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_maya+unsub...@googlegroups.com.



--
--:: Kurian ::--



--
--:: Kurian ::--

Justin Israel

unread,
Jul 8, 2015, 12:05:35 AM7/8/15
to python_in...@googlegroups.com
@likage - Run them multiple times and average the results. With file operations involved, you are bound to have variation. 

On Wed, Jul 8, 2015 at 4:00 PM Kurian O.S <kuri...@gmail.com> wrote:
And remember Justin is always right :D

Just a roll of the dice, actually.
 

Anthony Tan

unread,
Jul 8, 2015, 12:08:56 AM7/8/15
to python_in...@googlegroups.com
My first guess would be something else is happening on disk at the same time (or over the network), a 1.5% timing variation between runs is well within that range. Run it multiple times if you're curious and get some broader stats.
 
Also, gut feeling, try Kurian's code, but move the  time.time() call before the print statement such as:
 
import time
import maya.cmds as cmds
curTime = time.time()
fileToOpn = "/some/fld/somefile.mb"
cmds.file(fileToOpn, o=True,f=True)
doneTime = time.time()
print "%s to %s seconds" % (fileToOpn, doneTime - curTime)
 
This will stop your timer after you've finished the file open op, whereas previously I would not be at all surprised if you're timing both the file open operation *and* the output to console, where console outputs are relatively expensive in the grand scheme of things.
Reply all
Reply to author
Forward
0 new messages