]> git.sesse.net Git - stockfish/commitdiff
Debugging: print to file
authorMarco Costalba <mcostalba@gmail.com>
Sun, 14 Dec 2008 13:57:17 +0000 (14:57 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Sun, 14 Dec 2008 13:57:17 +0000 (14:57 +0100)
Print debug info on log file, not only on std::cout

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
src/misc.cpp
src/misc.h

index 357a3d14d26c3f791b91c7c83779708b275e2bf2..8691c3802aedcddf3b8cc7ac56fa6d40398d467f 100644 (file)
@@ -49,6 +49,9 @@ int gettimeofday(struct timeval * tp, struct timezone * tzp);
 //// Variables
 ////
 
 //// Variables
 ////
 
+static const std::string AppName = "Stockfish";
+static const std::string AppTag  = "";
+
 long dbg_cnt0 = 0;
 long dbg_cnt1 = 0;
 
 long dbg_cnt0 = 0;
 long dbg_cnt1 = 0;
 
@@ -73,6 +76,19 @@ void dbg_print_mean() {
             << (float)dbg_cnt1 / (dbg_cnt0 ? dbg_cnt0 : 1) << std::endl;
 }
 
             << (float)dbg_cnt1 / (dbg_cnt0 ? dbg_cnt0 : 1) << std::endl;
 }
 
+void dbg_print_hit_rate(std::ofstream& logFile) {
+
+  logFile << "Total " << dbg_cnt0 << " Hit " << dbg_cnt1
+          << " hit rate (%) " << (dbg_cnt1*100)/(dbg_cnt0 ? dbg_cnt0 : 1)
+          << std::endl;
+}
+
+void dbg_print_mean(std::ofstream& logFile) {
+
+  logFile << "Total " << dbg_cnt0 << " Mean "
+          << (float)dbg_cnt1 / (dbg_cnt0 ? dbg_cnt0 : 1) << std::endl;
+}
+
 /// engine_name() returns the full name of the current Stockfish version.
 /// This will be either "Stockfish YYMMDD" (where YYMMDD is the date when the
 /// program was compiled) or "Stockfish <version number>", depending on whether
 /// engine_name() returns the full name of the current Stockfish version.
 /// This will be either "Stockfish YYMMDD" (where YYMMDD is the date when the
 /// program was compiled) or "Stockfish <version number>", depending on whether
@@ -90,7 +106,9 @@ const std::string engine_name() {
       std::stringstream s;
       std::string day = (date[4] == ' ' ? date.substr(5, 1) : date.substr(4, 2));
 
       std::stringstream s;
       std::string day = (date[4] == ' ' ? date.substr(5, 1) : date.substr(4, 2));
 
-      s << "Stockfish " << date.substr(date.length() - 2) << std::setfill('0')
+      std::string name = AppName + " " + AppTag + " ";
+
+      s << name << date.substr(date.length() - 2) << std::setfill('0')
         << std::setw(2) << mon << std::setw(2) << day;
 
       return s.str();
         << std::setw(2) << mon << std::setw(2) << day;
 
       return s.str();
index 498263c68f9e7a19c0396638d53914832c29ad06..49758bec7677dec604499bd0dd459197a3943393 100644 (file)
@@ -26,6 +26,7 @@
 //// Includes
 ////
 
 //// Includes
 ////
 
+#include <fstream>
 #include <string>
 
 
 #include <string>
 
 
@@ -60,6 +61,7 @@ extern int Bioskey();
 ////
 //// Debug
 ////
 ////
 //// Debug
 ////
+
 extern bool dbg_show_mean;
 extern bool dbg_show_hit_rate;
 
 extern bool dbg_show_mean;
 extern bool dbg_show_hit_rate;
 
@@ -76,5 +78,7 @@ inline void dbg_mean_of(int v) { dbg_cnt0++; dbg_cnt1 += v; }
 
 extern void dbg_print_hit_rate();
 extern void dbg_print_mean();
 
 extern void dbg_print_hit_rate();
 extern void dbg_print_mean();
+extern void dbg_print_hit_rate(std::ofstream& logFile);
+extern void dbg_print_mean(std::ofstream& logFile);
 
 #endif // !defined(MISC_H_INCLUDED)
 
 #endif // !defined(MISC_H_INCLUDED)