Closed otonck closed 5 years ago
Hi Olivier
Thanks a lot for the hint. I have added void setSamples( const QPolygonF & );
The performance changes from 16 frames/sec to 45 frames/sec on my computer.
Regards Gudjon
Hi Gudjon,
thanks a lot. Closing this.
Regards, Olivier
Hi again,
this is not a bug but a performance improvement proposition.
I often need for my applications to display data changing over time, like in this simple example :
This prints on my computer a number of displayed frames per second of ~9fps,which is quite less that the ~25fps I get writing the same example in C++.
This seems related to the QwtPlotCurve setSamples method wrapper, which takes as input two python iterables (variables x and y in the example), converts them to
QVector<double>
objects (which is a costly operation when we have a lot of points) and finally passes them to the real Qwt setSamples method.One possible workaround would be to use a type which has a direct C++ <-> Python wrapper to pass the samples data and avoid this kind of performance hit : QPolygonF (which is just an explicit definition of the template type
QVector<QPointF>
).So, using this code :
and changing the sip file qwt_plot_curve.sip from this:
to this :
we get a great performance increase of the example above (from ~9fps to ~21fps in my computer, much closer to the performance of the C++ only solution).
Note that the added line must not be added after the
void setSamples( const QVector<QPointF> & );
line, so that the sip wrapper tests if the input is a QPolygonF before testing if it is aQVector<QPointF>
, in which case we have even lower performance (the sip part still iterates over the QPolygonF input to create aQVector<QPointF>
, and the python code that builds the QPolygonF takes additional time (compared to the first initial example) for nothing.Do you think this little change to qwt_plot_curve.sip could be merged ? I know we would take a lot of benefits from this for our projects.
Thanks again (again),
best regards, Olivier