X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fbenchmark.cpp;h=6e8357f29d0d5dc36ecb44eaceabd7d3c1d30a3e;hp=54455d88a7f1c83bc2676e8131e8951260508188;hb=a88e762b4ea4a3696ecc0431237f54090a5aa1e2;hpb=62ab7e46124b12fdbb310a9c8a8072ad05fc51b8 diff --git a/src/benchmark.cpp b/src/benchmark.cpp index 54455d88..6e8357f2 100644 --- a/src/benchmark.cpp +++ b/src/benchmark.cpp @@ -7,12 +7,12 @@ it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + Stockfish is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program. If not, see . */ @@ -53,7 +53,7 @@ const std::string BenchmarkPositions[] = { "4k2r/1pb2ppp/1p2p3/1R1p4/3P4/2r1PN2/P4PPP/1R4K1 b - 3 22", "3q2k1/pb3p1p/4pbp1/2r5/PpN2N2/1P2P2P/5PP1/Q2R2K1 b - - 4 26" }; - + //// //// Functions @@ -79,16 +79,15 @@ void benchmark(const std::string& commandLine) { if (val < 4 || val > 1024) { std::cerr << "The hash table size must be between 4 and 1024" << std::endl; - exit(EXIT_FAILURE); + Application::exit_with_failure(); } csStr >> threads; csVal >> val; if (val < 1 || val > THREAD_MAX) { - std::cerr << "The number of threads must be between 1 and " << THREAD_MAX - << std::endl; - exit(EXIT_FAILURE); - } + std::cerr << "The number of threads must be between 1 and " << THREAD_MAX << std::endl; + Application::exit_with_failure(); + } set_option_value("Hash", ttSize); set_option_value("Threads", threads); set_option_value("OwnBook", "false"); @@ -109,16 +108,15 @@ void benchmark(const std::string& commandLine) { maxNodes = val; std::vector positions; - + if (fileName != "default") { std::ifstream fenFile(fileName.c_str()); if (!fenFile.is_open()) { - std::cerr << "Unable to open positions file " << fileName - << std::endl; - exit(EXIT_FAILURE); - } + std::cerr << "Unable to open positions file " << fileName << std::endl; + Application::exit_with_failure(); + } std::string pos; while (fenFile.good()) { @@ -134,15 +132,19 @@ void benchmark(const std::string& commandLine) { int startTime = get_system_time(); std::vector::iterator it; int cnt = 1; + int64_t totalNodes = 0; for (it = positions.begin(); it != positions.end(); ++it, ++cnt) { Move moves[1] = {MOVE_NONE}; int dummy[2] = {0, 0}; Position pos(*it); std::cout << "\nProcessing position " << cnt << '/' << positions.size() << std::endl << std::endl; - think(pos, true, false, 0, dummy, dummy, 0, maxDepth, maxNodes, secsPerPos, moves); + if (!think(pos, true, false, 0, dummy, dummy, 0, maxDepth, maxNodes, secsPerPos, moves)) + break; + totalNodes += nodes_searched(); } - std::cout << "\n\nBenchmarking finished. Processing time (ms) " << get_system_time() - startTime - << std::endl << "Press any key to exit\n"; + std::cout << "\nProcessing time (ms) " << get_system_time() - startTime << std::endl + << "Nodes searched " << totalNodes << std::endl + << "Press any key to exit" << std::endl; std::cin >> fileName; }