Skip to content

Commit

Permalink
Add a Timer example script
Browse files Browse the repository at this point in the history
  • Loading branch information
boxanm committed Jan 12, 2025
1 parent 7fc4346 commit bbdeea9
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
3 changes: 3 additions & 0 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,6 @@ target_link_libraries(icp_advance_api pointmatcher)

add_executable(icp_customized icp_customized.cpp)
target_link_libraries(icp_customized pointmatcher)

add_executable(timer timer.cpp)
target_link_libraries(timer pointmatcher)
25 changes: 25 additions & 0 deletions examples/timer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include "pointmatcher/Timer.h"
#include <iostream>
#include <chrono>
#include <thread>

namespace Time {
using Clock = std::chrono::high_resolution_clock;
using TimePoint = std::chrono::time_point<Clock>;
}

int main() {
const Time::TimePoint time1 = Time::Clock::now();
PointMatcherSupport::timer t1;

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

const Time::TimePoint time2 = Time::Clock::now();
const double elapsed = t1.elapsed();

std::cout << "PM:timer time = " << elapsed << "\nchrono duration = "
<< std::chrono::duration_cast<std::chrono::nanoseconds>(time2 - time1).count() / double(1000000000)
<< " ms" << std::endl;

return 0;
}

0 comments on commit bbdeea9

Please sign in to comment.