Use std::chrono for time measurements
Diffstat:
2 files changed, 4 insertions(+), 5 deletions(-)
@@ -3,7 +3,7 @@
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
project(
Stellar
VERSION 1.2.5
VERSION 1.2.6
DESCRIPTION "Chess engine written in C++"
HOMEPAGE_URL https://git.dimitrijedobrota.com/stellar.git
LANGUAGES CXX
@@ -1,14 +1,13 @@
#ifndef STELLAR_TIME_H
#define STELLAR_TIME_H
#include <sys/time.h>
#include <chrono>
namespace timer {
inline uint32_t get_ms() {
struct timeval time{};
gettimeofday(&time, nullptr);
return time.tv_sec * 1000 + time.tv_usec / 1000;
const auto duration = std::chrono::system_clock::now().time_since_epoch();
return std::chrono::duration_cast<std::chrono::milliseconds>(duration).count();
}
} // namespace timer