首页 > 解决方案 > QCustomPlot 在图形中添加双精度需要很长时间

问题描述

我有这个代码:

QCustomPlot* plot;

QCPGraph* graph = plot->addGraph();

for(int i = 0; i < 50000; i++) {

    double x_l = static_cast<double>(buffer[i * 3]);
    double y_l = static_cast<double>(buffer[i * 3 + 1);
    double z_l = static_cast<double>(buffer[i * 3 + 2]);

    r = A * v + v1; // r and v1 and v are Eigen::Vector3d, A is Eigen::Matrix3d 

    graph->addData(x_l, x_l);
}

这个 for 循环需要 240 毫秒!!!!

如果我将最后一行替换为:

graph->addData(5.1121, 6.7457) //random number which are also double

for 循环需要 4 毫秒!!!

为什么差距这么大???

原来的行应该是:

graph->addData(r[0], r[1]);

但这也需要大约 300 毫秒。

标签: eigenqcustomplot

解决方案


推荐阅读