diff --git a/src/platform/timer.hpp b/src/platform/timer.hpp new file mode 100644 index 0000000..fd93431 --- /dev/null +++ b/src/platform/timer.hpp @@ -0,0 +1,37 @@ +#pragma once + +#include +#include + +namespace platform +{ + class Timer + { + private: + std::string label; + long int start; + long int end; + + long int gettime() + { + struct timeval tp; + gettimeofday(&tp, NULL); + long int ms = tp.tv_sec * 1000 + tp.tv_usec / 1000; + return ms; + }; + + public: + Timer(const char* lbl) : label(lbl) + { + this->label=std::string(lbl); + this->start = gettime(); + } + + ~Timer() + { + this->end=this->gettime(); + unsigned long diff = this->end - this->start; + std::cout << this->label << diff << std::endl; + } + }; +}; \ No newline at end of file