format support lib

This commit is contained in:
Erik Frojdh
2020-05-05 10:07:19 +02:00
parent e599bb7c24
commit ea4044e4b1
38 changed files with 775 additions and 854 deletions

19
slsSupportLib/include/Timer.h Executable file → Normal file
View File

@ -4,35 +4,32 @@
#include <iostream>
#include <string>
namespace sls{
namespace sls {
class Timer {
using clock = std::chrono::high_resolution_clock;
using time_point = std::chrono::time_point<clock>;
public:
Timer(std::string name = "0")
: t0(clock::now()), name_(name) {
}
Timer(std::string name = "0") : t0(clock::now()), name_(name) {}
double elapsed_ms() {
return std::chrono::duration<double, std::milli>(clock::now() - t0).count();
return std::chrono::duration<double, std::milli>(clock::now() - t0)
.count();
}
double elapsed_s() {
return std::chrono::duration<double>(clock::now() - t0).count();
}
void print_elapsed() {
std::cout << "Timer \"" << name_ << "\": Elapsed time " << elapsed_ms() << " ms\n";
}
void restart() {
t0 = clock::now();
std::cout << "Timer \"" << name_ << "\": Elapsed time " << elapsed_ms()
<< " ms\n";
}
void restart() { t0 = clock::now(); }
private:
time_point t0;
std::string name_;
};
}; //namespace sls
}; // namespace sls
#endif // TIMER_H