norlab-ulaval / libpointmatcher

An Iterative Closest Point (ICP) library for 2D and 3D mapping in Robotics
BSD 3-Clause "New" or "Revised" License
1.62k stars 548 forks source link

PointMatcherSupport::timer seems off #585

Open Louis-ThomasSchreiber opened 2 months ago

Louis-ThomasSchreiber commented 2 months ago

I tried using the default PerformanceInspector and the FileLogger available in libpointmatcher. The output times looked off: The mean iteration time x number of iterations is 10x the actual execution time. I tried investigating with this simple test:

const Time::V time1 = Time::Clock::now();
PointMatcherSupport::timer t1;
t1.restart();

this_thread::sleep_for(chrono::seconds(10));

const Time::V time2 = Time::Clock::now();

std::cout << "PM:timer time = " << t1.elapsed() << " chrono duration = "
          << std::chrono::duration_cast<std::chrono::milliseconds>(time2 - time1).count() << std::endl;

which outputs: PM:timer time = 4.9282e-05 chrono duration = 10000

I would expect:

PM:timer time = 10 chrono duration = 10000

Is there something I dont understand?

boxanm commented 2 months ago

Hello @Louis-ThomasSchreiber ! I tested your example, and everything seems functional on my side, as I'm getting the correct results:

╰─$ ./examples/timer
PM:timer time = 10.0046 chrono duration = 10004 ms

Can you provide more information about your system? If you are on Ubuntu or MacOS, you run one of the following scripts: utest/listVersionsUbuntu.sh or utest/listVersionsMacOS.sh.