X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fbenchmark.cpp;h=9f32dbae3a2f3e6a1d2b0c76152c59090b6e59fb;hp=45304671993c1d49c07cae6899bac14fa920a965;hb=4e59c5c2746741e7aedd451ea16b792d1568e5c4;hpb=c4517c013cf8cf1a388c94d90727dbe08938cc5a diff --git a/src/benchmark.cpp b/src/benchmark.cpp index 45304671..9f32dbae 100644 --- a/src/benchmark.cpp +++ b/src/benchmark.cpp @@ -28,7 +28,7 @@ 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", @@ -60,6 +60,7 @@ static const string Defaults[] = { void benchmark(int argc, char* argv[]) { vector fenList; + Search::LimitsType limits; int64_t totalNodes; int time; @@ -76,14 +77,17 @@ void benchmark(int argc, char* argv[]) { // Search should be limited by nodes, time or depth ? if (valType == "nodes") - Search::Limits.maxNodes = atoi(valStr.c_str()); + limits.maxNodes = atoi(valStr.c_str()); else if (valType == "time") - Search::Limits.maxTime = 1000 * atoi(valStr.c_str()); // maxTime is in ms + limits.maxTime = 1000 * atoi(valStr.c_str()); // maxTime is in ms else - Search::Limits.maxDepth = atoi(valStr.c_str()); + 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,35 +104,30 @@ 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 ! - Search::RootMoves.push_back(MOVE_NONE); totalNodes = 0; time = get_system_time(); for (size_t i = 0; i < fenList.size(); i++) { Position pos(fenList[i], false, 0); - Search::RootPosition = &pos; cerr << "\nBench position: " << i + 1 << '/' << fenList.size() << endl; if (valType == "perft") { - int64_t cnt = Search::perft(pos, Search::Limits.maxDepth * ONE_PLY); + int64_t cnt = Search::perft(pos, limits.maxDepth * ONE_PLY); - cerr << "\nPerft " << Search::Limits.maxDepth + cerr << "\nPerft " << limits.maxDepth << " nodes counted: " << cnt << endl; totalNodes += cnt; } else { - Threads.start_thinking(false); - totalNodes += pos.nodes_searched(); + Threads.start_thinking(pos, limits, vector(), false); + totalNodes += Search::RootPosition.nodes_searched(); } }