gpt4 book ai didi

c++ - 解释 gprof 输出并识别此特征函数

转载 作者:行者123 更新时间:2023-11-28 05:17:18 25 4
gpt4 key购买 nike

我刚刚运行 gprof 来分析我的一些代码。这是平面轮廓的前几行。第一个功能使用了超过 75% 的时间。那是什么功能?关于我如何滥用 Eigen 库,它告诉我什么?

Flat profile:

Each sample counts as 0.01 seconds.
% cumulative self self total
time seconds seconds calls Ts/call Ts/call name
75.16 368.61 368.61 void Eigen::internal::call_assignment_no_alias<Eigen::Matrix<double, -1, 1, 0, -1, 1>, Eigen::Matrix<double, -1, 1, 0, -1, 1>, Eigen::internal::assign_op<double> >(Eigen::Matrix<double, -1, 1, 0, -1, 1>&, Eigen::Matrix<double, -1, 1, 0, -1, 1> const&, Eigen::internal::assign_op<double> const&)

下面是格式更好一点的函数名称:

void Eigen::internal::call_assignment_no_alias<Eigen::Matrix<double, -1, 1, 0, -1, 1>, 
Eigen::Matrix<double, -1, 1, 0, -1, 1>,
Eigen::internal::assign_op<double> >(Eigen::Matrix<double, -1, 1, 0, -1, 1>&,
Eigen::Matrix<double, -1, 1, 0, -1, 1> const&,
Eigen::internal::assign_op<double> const&)

最佳答案

这个函数赋值一个MatrixXd到另一个:

MatrixXd a, b;
b = a;

这意味着大部分时间都花在了复制矩阵上。

因此请确保您在编译时启用了优化(-O3),否则您的分析结果将毫无意义。如果是这样,请确保通过引用而不是值传递矩阵,使用 std::vector<MatrixXd> 时要小心等

关于c++ - 解释 gprof 输出并识别此特征函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42370287/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com