mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-20 00:56:39 +08:00
Rewrite time measurement code
Introduce and use a new Time class designed after QTime, from Qt framework. Should be a more clear and self documented code. As an added benefit we now use 64 bits internally to get millisecs from system time. This avoids to wrap around to 0 every 2^32 milliseconds, which is 49.71 days. No functional change. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
10
src/uci.cpp
10
src/uci.cpp
@@ -243,19 +243,19 @@ namespace {
|
||||
|
||||
void perft(Position& pos, istringstream& is) {
|
||||
|
||||
int depth, time;
|
||||
int depth;
|
||||
|
||||
if (!(is >> depth))
|
||||
return;
|
||||
|
||||
time = system_time();
|
||||
Time time = Time::current_time();
|
||||
|
||||
int64_t n = Search::perft(pos, depth * ONE_PLY);
|
||||
|
||||
time = system_time() - time;
|
||||
int e = time.elapsed();
|
||||
|
||||
std::cout << "\nNodes " << n
|
||||
<< "\nTime (ms) " << time
|
||||
<< "\nNodes/second " << int(n / (time / 1000.0)) << std::endl;
|
||||
<< "\nTime (ms) " << e
|
||||
<< "\nNodes/second " << int(n / (e / 1000.0)) << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user