stellar

Stellar - UCI Chess engine written in C++20
git clone git://git.dimitrijedobrota.com/stellar.git
Log | Files | Refs | README | LICENSE

commit 141a5b8bd8e68ee047fc574f3455e4a6e15ffab2
parent bc10eb327280374ae4808e9b1022e9eb70304e2f
Author: Dimitrije Dobrota <mail@dimitrijedobrota.com>
Date:   Mon, 11 Mar 2024 16:30:58 +0000

Use std::chrono for time measurements

Diffstat:
MCMakeLists.txt | 2+-
Msrc/utils/timer.hpp | 7+++----
2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt @@ -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 diff --git a/src/utils/timer.hpp b/src/utils/timer.hpp @@ -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