18 lines
434 B
C++
18 lines
434 B
C++
#include "timer.h"
|
|
|
|
#include <chrono>
|
|
#include <iostream>
|
|
|
|
Timer::Timer(std::string_view name) : name_(name) { start(); };
|
|
|
|
void Timer::start() { start_ = std::chrono::high_resolution_clock::now(); }
|
|
|
|
void Timer::stop() {
|
|
auto end = std::chrono::high_resolution_clock::now();
|
|
|
|
auto duration =
|
|
std::chrono::duration_cast<std::chrono::microseconds>(end - start_);
|
|
|
|
std::cout << name_ << " took " << duration << std::endl;
|
|
}
|