Hi, everyone:
I'm performance tuning some code, and running into an issue that I could use
some help with. When I run this code:
def loopWire2(w):
edges = TopTools.TopTools_HSequenceOfShape();
topexp = TopExp.TopExp_Explorer();
topexp.Init(w,TopAbs.TopAbs_EDGE);
while topexp.More():
edges.Append(topexp.Current());
topexp.Next();
return edges;
s = loopWire2( ( a wire with about 155 linear edges ) );
..and I profile it as it runs with cProfile, i see something like this:
ncalls tottime percall cumtime percall filename:lineno(function)
1 0.000 0.000 * 0.009 * 0.009 <string>:1(<module>)
1 0.002 0.002 0.009 0.009
curveIntersections.py:67(loopWire2)
155 0.001 0.000 *0.005* 0.000
c:\python266\lib\site-packages\OCC\TopoDS.py:928(__del__)
157 0.002 0.000 *0.003* 0.000
c:\python266\lib\site-packages\OCC\GarbageCollector.py:75(collect_object)
155 0.001 0.000 0.001 0.000
c:\python266\lib\site-packages\OCC\TopoDS.py:741(<lambda>)
Note that a large portion of the execution time is used in creating and
collecting TopoDS objects, which i assume are implicitly created in
TopExp_Explorer.
I first noticed this when code that was iterating over wires with large edge
counts was taking a longer than usual time. Though the above runs pretty
fast ( 4ms in real time, 9ms profiled ), it doesnt take long for this to add
up fast. The code above is an optimized version of what i started with,
which ran twice as slow as this one because I used casts to topds_edge,
which created more objects that had to be collected.
I'm sure I could disable the garbage collector, but that would just defer
the problem to later.
Does anyone know how to prevent the extra overhead in this case? I have
also tried WireExplorer and Utils.Topology-- they appear to perform worse--
though mostly due to the same issue: collecting garbage.
So, I am at a loss ( besides going to C++ code--ew ) on how to make the
above code run faster. Looping through 155 edges shouldnt take 4ms should
it?
Here are my operating parameters:
windows xp (32 bit )
python 2.6.6 (32 bit )
pythonocc 0.5 ( installed with all-in-one: thus OCC 6.3.0 )
thanks in advance for the ideas/help!
_______________________________________________
Pythonocc-users mailing list
[email protected]
https://mail.gna.org/listinfo/pythonocc-users