From: Marco Costalba Date: Sun, 14 Dec 2008 13:57:17 +0000 (+0100) Subject: Debugging: print to file X-Git-Url: https://git.sesse.net/?p=stockfish;a=commitdiff_plain;h=5f8f83bc0510039529040e7e877fa66fcb28005e Debugging: print to file Print debug info on log file, not only on std::cout Signed-off-by: Marco Costalba --- diff --git a/src/misc.cpp b/src/misc.cpp index 357a3d14..8691c380 100644 --- a/src/misc.cpp +++ b/src/misc.cpp @@ -49,6 +49,9 @@ int gettimeofday(struct timeval * tp, struct timezone * tzp); //// Variables //// +static const std::string AppName = "Stockfish"; +static const std::string AppTag = ""; + 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; } +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 ", 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)); - 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(); diff --git a/src/misc.h b/src/misc.h index 498263c6..49758bec 100644 --- a/src/misc.h +++ b/src/misc.h @@ -26,6 +26,7 @@ //// Includes //// +#include #include @@ -60,6 +61,7 @@ extern int Bioskey(); //// //// Debug //// + 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(std::ofstream& logFile); +extern void dbg_print_mean(std::ofstream& logFile); #endif // !defined(MISC_H_INCLUDED)