You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

42 lines
1.2 KiB

//
// Created by cflin on 7/9/23.
//
#ifndef TOP3D_TIMER_H
#define TOP3D_TIMER_H
#include <iostream>
#include <chrono>
namespace da {
namespace sha {
namespace top {
class Timer {
public:
static void tic() {
start_timepoint_ = std::chrono::high_resolution_clock::now();
}
static void toc() {
auto end_timepoint = std::chrono::high_resolution_clock::now();
auto start = std::chrono::time_point_cast<std::chrono::microseconds>(
start_timepoint_).time_since_epoch().count();
auto end = std::chrono::time_point_cast<std::chrono::microseconds>(
end_timepoint).time_since_epoch().count();
auto duration = end - start;
double ms = duration * 0.001;
std::cout << "Elapsed time: " << ms << " ms" << std::endl;
}
private:
static std::chrono::time_point<std::chrono::high_resolution_clock> start_timepoint_;
};
} // da
} // sha
} // top
#endif //TOP3D_TIMER_H