Restore NPS output for Perft

Previously it was possible to also get the node counter after running a bench with perft, i.e.
`./stockfish bench 1 1 5 current perft`, caused by a small regression from the uci refactoring.

```
Nodes searched: 4865609

===========================
Total time (ms) : 18
Nodes searched  : 4865609
Nodes/second    : 270311611
````

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

No functional change
This commit is contained in:
Disservin
2024-04-22 19:24:10 +02:00
parent d47aa639bd
commit ddd250b9d6
7 changed files with 45 additions and 20 deletions
+22 -4
View File
@@ -219,7 +219,11 @@ Search::LimitsType UCIEngine::parse_limits(std::istream& is) {
void UCIEngine::go(std::istringstream& is) {
Search::LimitsType limits = parse_limits(is);
engine.go(limits);
if (limits.perft)
perft(limits);
else
engine.go(limits);
}
void UCIEngine::bench(std::istream& args) {
@@ -233,7 +237,7 @@ void UCIEngine::bench(std::istream& args) {
on_update_full(i, options["UCI_ShowWDL"]);
});
std::vector<std::string> list = setup_bench(engine.fen(), args);
std::vector<std::string> list = Benchmark::setup_bench(engine.fen(), args);
num = count_if(list.begin(), list.end(),
[](const std::string& s) { return s.find("go ") == 0 || s.find("eval") == 0; });
@@ -251,8 +255,16 @@ void UCIEngine::bench(std::istream& args) {
<< std::endl;
if (token == "go")
{
go(is);
engine.wait_for_search_finished();
Search::LimitsType limits = parse_limits(is);
if (limits.perft)
nodes = perft(limits);
else
{
engine.go(limits);
engine.wait_for_search_finished();
}
nodes += nodesSearched;
nodesSearched = 0;
}
@@ -288,6 +300,12 @@ void UCIEngine::setoption(std::istringstream& is) {
engine.get_options().setoption(is);
}
std::uint64_t UCIEngine::perft(const Search::LimitsType& limits) {
auto nodes = engine.perft(engine.fen(), limits.perft, engine.get_options()["UCI_Chess960"]);
sync_cout << "\nNodes searched: " << nodes << "\n" << sync_endl;
return nodes;
}
void UCIEngine::position(std::istringstream& is) {
std::string token, fen;