-/// benchmark() runs a simple benchmark by letting Glaurung analyze 15
-/// positions for 60 seconds each. There are two parameters; the
-/// transposition table size and the number of search threads that should
-/// be used. The analysis is written to a file named bench.txt.
+/// benchmark() runs a simple benchmark by letting Stockfish analyze a set
+/// of positions for a given limit each. There are five parameters: the
+/// transposition table size, the number of search threads that should
+/// be used, the limit value spent for each position (optional, default is
+/// depth 13), an optional file name where to look for positions in FEN
+/// format (defaults are the positions defined above) and the type of the
+/// limit value: depth (default), time in secs or number of nodes.
+
+void benchmark(const Position& current, istream& is) {
+
+ string token;
+ Search::LimitsType limits;
+ vector<string> fens;
+
+ // Assign default values to missing arguments
+ string ttSize = (is >> token) ? token : "32";
+ string threads = (is >> token) ? token : "1";
+ string limit = (is >> token) ? token : "13";
+ string fenFile = (is >> token) ? token : "default";
+ string limitType = (is >> token) ? token : "depth";
+
+ Options["Hash"] = ttSize;
+ Options["Threads"] = threads;
+ TT.clear();
+
+ if (limitType == "time")
+ limits.movetime = 1000 * atoi(limit.c_str()); // movetime is in ms
+
+ else if (limitType == "nodes")
+ limits.nodes = atoi(limit.c_str());
+
+ else if (limitType == "mate")
+ limits.mate = atoi(limit.c_str());
+
+ else
+ limits.depth = atoi(limit.c_str());