]> git.sesse.net Git - stockfish/blobdiff - src/benchmark.cpp
Use bench to implement UI 'perft' command
[stockfish] / src / benchmark.cpp
index 0417313cbb6bf3ac22ba5733cd77bda68fc3212f..5d8757a61f49dd7214e48038746f0c93cdfe6ffd 100644 (file)
@@ -19,7 +19,7 @@
 
 #include <fstream>
 #include <iostream>
-#include <sstream>
+#include <istream>
 #include <vector>
 
 #include "misc.h"
@@ -58,11 +58,11 @@ static const char* Defaults[] = {
 /// 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(istringstream& is) {
+void benchmark(const Position& current, istream& is) {
 
   string token;
   Search::LimitsType limits;
-  vector<string> fens(Defaults, Defaults + 16);
+  vector<string> fens;
 
   // Assign default values to missing arguments
   string ttSize    = (is >> token) ? token : "128";
@@ -83,14 +83,14 @@ void benchmark(istringstream& is) {
   else
       limits.depth = atoi(limit.c_str());
 
-  if (fenFile == "current")
-  {
-      fens.clear();
-      fens.push_back(Search::RootPosition.to_fen());
-  }
-  else if (fenFile != "default")
+  if (fenFile == "default")
+      fens.assign(Defaults, Defaults + 16);
+
+  else if (fenFile == "current")
+      fens.push_back(current.to_fen());
+
+  else
   {
-      fens.clear();
       string fen;
       ifstream file(fenFile.c_str());