Hi,
A while ago I did some experiments with python based data export and
found that there are very significant speed differenced between Python
API and C++ API when using the MFnPfxGeometry class. I created a simple
pfxdata export command using both languages (using similar queries,
loops and stuff) and found that in my test scenes the speed difference
is about 8 - 10 times.
(I removed every string operation, file output, data accumulation stuff,
the command only did the important data query and all variable
allocations were optimized.)
After Matthew Chapman's suggestion I tried doing some profiling using
python's profiler library (cool stuff BTW) and got the data attached to
the end of the mail. The question is: is there anything I can do to
speed up the code based on the profiler's output (that I can't really
comprehend by myself) or do I have to simply forget the Python API as an
exporter? Or is it just a limitation of the MFnPfxGeometry class? Do you
experience such speed differences in other API areas?
Thanks for any tips in advance!
Cheers,
Szabolcs
---
8211552 function calls in 40.582 CPU seconds
Ordered by: cumulative time
List reduced from 75 to 10 due to restriction <10>
ncalls tottime percall cumtime percall filename:lineno(function)
1 0.000 0.000 40.582 40.582
profile:0(profileTestProcNoStrings())
1 0.000 0.000 40.581 40.581 <string>:1(?)
1 4.384 4.384 40.581 40.581 <maya
console>:2(profileTestProcNoStrings)
384000 2.417 0.000 29.618 0.000
C:\engserv\rbuild\164\build\wrk\optim\runTime\Python\Lib\site-packages\maya\OpenMaya.py:9481(__getitem__)
384000 3.924 0.000 27.201 0.000
C:\engserv\rbuild\164\build\wrk\optim\runTime\Python\Lib\site-packages\maya\OpenMaya.py:9565(__init__)
1254430 5.139 0.000 16.562 0.000
C:\engserv\rbuild\164\build\wrk\optim\runTime\Python\Lib\site-packages\maya\OpenMaya.py:21(_swig_setattr)
1254430 7.826 0.000 11.423 0.000
C:\engserv\rbuild\164\build\wrk\optim\runTime\Python\Lib\site-packages\maya\OpenMaya.py:7(_swig_setattr_nondynamic)
422420 2.586 0.000 7.333 0.000 :0(hasattr)
384000 1.352 0.000 5.699 0.000
C:\engserv\rbuild\164\build\wrk\optim\runTime\Python\Lib\site-packages\maya\OpenMaya.py:9505(<lambda>)
384000 1.422 0.000 4.313 0.000
C:\engserv\rbuild\164\build\wrk\optim\runTime\Python\Lib\site-packages\maya\OpenMaya.py:9507(<lambda>)
Ordered by: internal time
ncalls tottime percall cumtime percall filename:lineno(function)
1254430 7.826 0.000 11.423 0.000
C:\engserv\rbuild\164\build\wrk\optim\runTime\Python\Lib\site-packages\maya\OpenMaya.py:7(_swig_setattr_nondynamic)
1254430 5.139 0.000 16.562 0.000
C:\engserv\rbuild\164\build\wrk\optim\runTime\Python\Lib\site-packages\maya\OpenMaya.py:21(_swig_setattr)
1 4.384 4.384 40.581 40.581 <maya
console>:2(profileTestProcNoStrings)
384000 3.924 0.000 27.201 0.000
C:\engserv\rbuild\164\build\wrk\optim\runTime\Python\Lib\site-packages\maya\OpenMaya.py:9565(__init__)
1728070 3.050 0.000 3.050 0.000 :0(get)
422420 2.586 0.000 7.333 0.000 :0(hasattr)
384000 2.417 0.000 29.618 0.000
C:\engserv\rbuild\164\build\wrk\optim\runTime\Python\Lib\site-packages\maya\OpenMaya.py:9481(__getitem__)
409610 2.383 0.000 3.084 0.000
C:\engserv\rbuild\164\build\wrk\optim\runTime\Python\Lib\site-packages\maya\OpenMaya.py:24(_swig_getattr)
384000 1.490 0.000 1.490 0.000
C:\engserv\rbuild\164\build\wrk\optim\runTime\Python\Lib\site-packages\maya\OpenMaya.py:9524(__getitem__)
384000 1.422 0.000 4.313 0.000
C:\engserv\rbuild\164\build\wrk\optim\runTime\Python\Lib\site-packages\maya\OpenMaya.py:9507(<lambda>)
Ordered by: call count
ncalls tottime percall cumtime percall filename:lineno(function)
1728070 3.050 0.000 3.050 0.000 :0(get)
1254430 5.139 0.000 16.562 0.000
C:\engserv\rbuild\164\build\wrk\optim\runTime\Python\Lib\site-packages\maya\OpenMaya.py:21(_swig_setattr)
1254430 7.826 0.000 11.423 0.000
C:\engserv\rbuild\164\build\wrk\optim\runTime\Python\Lib\site-packages\maya\OpenMaya.py:7(_swig_setattr_nondynamic)
422420 2.586 0.000 7.333 0.000 :0(hasattr)
422420 1.402 0.000 1.402 0.000 :0(isinstance)
409610 2.383 0.000 3.084 0.000
C:\engserv\rbuild\164\build\wrk\optim\runTime\Python\Lib\site-packages\maya\OpenMaya.py:24(_swig_getattr)
384000 0.803 0.000 0.803 0.000
C:\engserv\rbuild\164\build\wrk\optim\runTime\Python\Lib\site-packages\maya\OpenMaya.py:9517(__del__)
384000 3.924 0.000 27.201 0.000
C:\engserv\rbuild\164\build\wrk\optim\runTime\Python\Lib\site-packages\maya\OpenMaya.py:9565(__init__)
384000 1.352 0.000 5.699 0.000
C:\engserv\rbuild\164\build\wrk\optim\runTime\Python\Lib\site-packages\maya\OpenMaya.py:9505(<lambda>)
384000 1.422 0.000 4.313 0.000
C:\engserv\rbuild\164\build\wrk\optim\runTime\Python\Lib\site-packages\maya\OpenMaya.py:9507(<lambda>)
--~--~---------~--~----~------------~-------~--~----~
Yours,
Maya-Python Club Team.
-~----------~----~----~----~------~----~------~--~---