X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;ds=sidebyside;f=src%2Fbenchmark.cpp;h=464bab78ec29b72e59d26b247275d46f820adcde;hb=0a6532a39d2e2cfd92ba0a2c4fa8c6ad6c29b581;hp=95dd88ac01fad7b525eb65a90d3e0cce1ab40e54;hpb=ff1ecb5d6c58b665efc9df6779c05b9e7a61d603;p=stockfish diff --git a/src/benchmark.cpp b/src/benchmark.cpp index 95dd88ac..464bab78 100644 --- a/src/benchmark.cpp +++ b/src/benchmark.cpp @@ -23,11 +23,12 @@ #include "position.h" #include "search.h" +#include "thread.h" #include "ucioption.h" using namespace std; -static const string Defaults[] = { +static const char* Defaults[] = { "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1", "r3k2r/p1ppqpb1/bn2pnp1/3PN3/1p2P3/2N2Q1p/PPPBBPPP/R3K2R w KQkq - 0 10", "8/2p5/3p4/KP5r/1R3p1k/8/4P1P1/8 w - - 0 11", @@ -59,7 +60,7 @@ static const string Defaults[] = { void benchmark(int argc, char* argv[]) { vector fenList; - SearchLimits limits; + Search::LimitsType limits; int64_t totalNodes; int time; @@ -70,9 +71,9 @@ void benchmark(int argc, char* argv[]) { string fenFile = argc > 5 ? argv[5] : "default"; string valType = argc > 6 ? argv[6] : "depth"; - Options["Hash"].set_value(ttSize); - Options["Threads"].set_value(threads); - Options["OwnBook"].set_value("false"); + Options["Hash"] = ttSize; + Options["Threads"] = threads; + Options["OwnBook"] = false; // Search should be limited by nodes, time or depth ? if (valType == "nodes") @@ -83,7 +84,10 @@ void benchmark(int argc, char* argv[]) { limits.maxDepth = atoi(valStr.c_str()); // Do we need to load positions from a given FEN file? - if (fenFile != "default") + if (fenFile == "default") + for (int i = 0; *Defaults[i]; i++) + fenList.push_back(Defaults[i]); + else { string fen; ifstream f(fenFile.c_str()); @@ -100,24 +104,20 @@ void benchmark(int argc, char* argv[]) { f.close(); } - else // Load default positions - for (int i = 0; !Defaults[i].empty(); i++) - fenList.push_back(Defaults[i]); // Ok, let's start the benchmark ! totalNodes = 0; - time = get_system_time(); + time = system_time(); for (size_t i = 0; i < fenList.size(); i++) { - Move moves[] = { MOVE_NONE }; Position pos(fenList[i], false, 0); cerr << "\nBench position: " << i + 1 << '/' << fenList.size() << endl; if (valType == "perft") { - int64_t cnt = perft(pos, limits.maxDepth * ONE_PLY); + int64_t cnt = Search::perft(pos, limits.maxDepth * ONE_PLY); cerr << "\nPerft " << limits.maxDepth << " nodes counted: " << cnt << endl; @@ -126,14 +126,12 @@ void benchmark(int argc, char* argv[]) { } else { - if (!think(pos, limits, moves)) - break; - - totalNodes += pos.nodes_searched(); + Threads.start_thinking(pos, limits, vector(), false); + totalNodes += Search::RootPosition.nodes_searched(); } } - time = get_system_time() - time; + time = system_time() - time; cerr << "\n===============================" << "\nTotal time (ms) : " << time