]> git.sesse.net Git - stockfish/commitdiff
Introduce depth limited benchmarking
authorMarco Costalba <mcostalba@gmail.com>
Sat, 22 Nov 2008 10:02:05 +0000 (11:02 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Sat, 22 Nov 2008 10:02:05 +0000 (11:02 +0100)
Also print some more info.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
src/benchmark.cpp
src/main.cpp
src/search.cpp

index 5102b369d2ea0457f4afe0c02e6de52cf3197d1f..4c2ba7472703a3c88979678c30a78361d8b51e76 100644 (file)
@@ -71,8 +71,8 @@ void benchmark(const std::string& commandLine) {
 
   std::istringstream csVal(commandLine);
   std::istringstream csStr(commandLine);
 
   std::istringstream csVal(commandLine);
   std::istringstream csStr(commandLine);
-  std::string ttSize, threads, fileName;
-  int val, secsPerPos;
+  std::string ttSize, threads, fileName, timeOrDepth;
+  int val, secsPerPos, maxDepth = 0;
 
   csStr >> ttSize;
   csVal >> val;
 
   csStr >> ttSize;
   csVal >> val;
@@ -97,6 +97,15 @@ void benchmark(const std::string& commandLine) {
 
   csVal >> secsPerPos;
   csVal >> fileName;
 
   csVal >> secsPerPos;
   csVal >> fileName;
+  csVal >> timeOrDepth;
+
+  if (timeOrDepth == "time")
+      secsPerPos *= 1000;
+  else
+  {
+      maxDepth = secsPerPos;
+      secsPerPos = 0;
+  }
 
   std::vector<std::string> positions;
   
 
   std::vector<std::string> positions;
   
@@ -121,12 +130,18 @@ void benchmark(const std::string& commandLine) {
       for (int i = 0; i < 16; i++)
           positions.push_back(std::string(BenchmarkPositions[i]));
 
       for (int i = 0; i < 16; i++)
           positions.push_back(std::string(BenchmarkPositions[i]));
 
+  int startTime = get_system_time();
   std::vector<std::string>::iterator it;
   std::vector<std::string>::iterator it;
-  for (it = positions.begin(); it != positions.end(); ++it)\r
+  int cnt = 1;
+  for (it = positions.begin(); it != positions.end(); ++it, ++cnt)
   {
   {
-      Move moves[1] = {MOVE_NONE};\r
-      int dummy[2] = {0, 0};\r
+      Move moves[1] = {MOVE_NONE};
+      int dummy[2] = {0, 0};
       Position pos(*it);
       Position pos(*it);
-      think(pos, true, false, 0, dummy, dummy, 0, 0, 0, secsPerPos * 1000, moves);\r
+      std::cout << "\nProcessing position " << cnt << '/' << positions.size() << std::endl << std::endl;
+      think(pos, true, false, 0, dummy, dummy, 0, maxDepth, 0, secsPerPos, moves);
   }
   }
+  std::cout << "\n\nBenchmarking finished. Processing time (ms) " << get_system_time() - startTime
+            << std::endl << "Press any key to exit\n";
+  std::cin >> fileName;
 }
 }
index 9d2e1ef28c080061d0562f229c569ab5b5e0dcae..89ca9e8ec6fa976d3c7127f78a60a3cbe77eb894 100644 (file)
@@ -71,16 +71,18 @@ int main(int argc, char *argv[]) {
   // Process command line arguments
   if (argc >= 2 && string(argv[1]) == "bench")
   {
   // Process command line arguments
   if (argc >= 2 && string(argv[1]) == "bench")
   {
-      if (argc < 4 || argc > 6)
+      if (argc < 4 || argc > 7)
       {
         std::cout << "Usage: glaurung bench <hash size> <threads> "
       {
         std::cout << "Usage: glaurung bench <hash size> <threads> "
-                  << "[time = 60s] [fen positions file = default]"
+                  << "[time = 60s] [fen positions file = default] "
+                  << "[time or depth limited = time]"
                   << std::endl;
         exit(0);
       }
       string time = argc > 4 ? argv[4] : "60";
       string fen = argc > 5 ? argv[5] : "default";
                   << std::endl;
         exit(0);
       }
       string time = argc > 4 ? argv[4] : "60";
       string fen = argc > 5 ? argv[5] : "default";
-      benchmark(string(argv[2]) + " " + string(argv[3]) + " " + time + " " + fen);
+      string dt = argc > 6 ? argv[6] : "time";
+      benchmark(string(argv[2]) + " " + string(argv[3]) + " " + time + " " + fen + " " + dt);
       return 0;
   }
 
       return 0;
   }
 
index c463ec393e42c98ed54880fc533f4fe0370b4210..3f4ad24ca17652319456568ef0169d1ab1ecd7e4 100644 (file)
@@ -431,7 +431,7 @@ void think(const Position &pos, bool infinite, bool ponder, int side_to_move,
 
   if (!movesToGo) // Sudden death time control
   {
 
   if (!movesToGo) // Sudden death time control
   {
-      if (increment)
+      if (myIncrement)
       {
           MaxSearchTime = myTime / 30 + myIncrement;
           AbsoluteMaxSearchTime = Max(myTime / 4, myIncrement - 100);
       {
           MaxSearchTime = myTime / 30 + myIncrement;
           AbsoluteMaxSearchTime = Max(myTime / 4, myIncrement - 100);