1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-07-11 19:49:14 +00:00

Debugging: print to file

Print debug info on log file, not only on std::cout

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
Marco Costalba 2008-12-14 14:57:17 +01:00
parent 8ee3124487
commit 5f8f83bc05
2 changed files with 23 additions and 1 deletions

View 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_cnt0 = 0;
long dbg_cnt1 = 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. /// engine_name() returns the full name of the current Stockfish version.
/// This will be either "Stockfish YYMMDD" (where YYMMDD is the date when the /// This will be either "Stockfish YYMMDD" (where YYMMDD is the date when the
/// program was compiled) or "Stockfish <version number>", depending on whether /// program was compiled) or "Stockfish <version number>", depending on whether
@ -90,7 +106,9 @@ const std::string engine_name() {
std::stringstream s; std::stringstream s;
std::string day = (date[4] == ' ' ? date.substr(5, 1) : date.substr(4, 2)); 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; << std::setw(2) << mon << std::setw(2) << day;
return s.str(); return s.str();

View 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_mean;
extern bool dbg_show_hit_rate; 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_hit_rate();
extern void dbg_print_mean(); 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)