Refactor elapsed time checks in search

Small improvement of the elapsed time usage in search, makes the code easier to read overall.
Also Search::Worker::iterative_deepening() now only checks the elapsed time once, instead of 3 times in a row.

Non Regression STC:
https://tests.stockfishchess.org/tests/view/6617005d5a4693796d965c3c
LLR: 2.97 (-2.94,2.94) <-1.75,0.25>
Total: 61024 W: 16002 L: 15806 D: 29216
Ptnml(0-2): 243, 6874, 16102, 7030, 263

closes https://github.com/official-stockfish/Stockfish/pull/5163

No functional change
This commit is contained in:
Disservin
2024-04-10 23:10:07 +02:00
committed by Joost VandeVondele
parent 432995ad82
commit d3fc1d835e
4 changed files with 21 additions and 18 deletions

View File

@@ -19,7 +19,6 @@
#ifndef TIMEMAN_H_INCLUDED
#define TIMEMAN_H_INCLUDED
#include <cstddef>
#include <cstdint>
#include "misc.h"
@@ -41,7 +40,10 @@ class TimeManagement {
TimePoint optimum() const;
TimePoint maximum() const;
TimePoint elapsed(std::size_t nodes) const;
template<typename FUNC>
TimePoint elapsed(FUNC nodes) const {
return useNodesTime ? TimePoint(nodes()) : now() - startTime;
}
void clear();
void advance_nodes_time(std::int64_t nodes);