mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-19 00:26:33 +08: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:
20
src/misc.cpp
20
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 <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));
|
||||
|
||||
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();
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
//// Includes
|
||||
////
|
||||
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user