ROS利用C++测试代码运行时间

C++11

#include 
#include 
int main() {
    auto start = std::chrono::high_resolution_clock::now();
    // operation to be timed ...
    auto finish = std::chrono::high_resolution_clock::now();
    std::cout << std::chrono::duration_cast(finish-start).count() << "ns\n";
}

ROS

ros::Time time_begin = ros::Time::now();
ros::Duration(1.5).sleep();
ros::Time time_end = ros::Time::now();
ros::Duration duration = time_end - time_begin;
ROS_INFO("Slept for %lf secs", duration.toSec());

你可能感兴趣的:(Software)