Debugging: move debug function definitions in misc.cpp
authorMarco Costalba <mcostalba@gmail.com>
Sun, 14 Dec 2008 16:26:05 +0000 (17:26 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Sun, 14 Dec 2008 16:26:05 +0000 (17:26 +0100)
Also activate writing on log file.

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

index 8691c3802aedcddf3b8cc7ac56fa6d40398d467f..49a17dcb8661c889f176e990a9aa3453a9c1d922 100644 (file)
@@ -37,6 +37,7 @@ int gettimeofday(struct timeval * tp, struct timezone * tzp);
 
 #endif
 
+#include <cassert>
 #include <cstdio>
 #include <iomanip>
 #include <iostream>
@@ -63,6 +64,42 @@ bool dbg_show_hit_rate = false;
 //// Functions
 ////
 
+void dbg_hit_on(bool b) {
+
+    assert(!dbg_show_mean);
+    dbg_show_hit_rate = true;
+    dbg_cnt0++;
+    if (b)
+        dbg_cnt1++;
+}
+
+void dbg_hit_on_c(bool c, bool b) {
+
+    if (c)
+        dbg_hit_on(b);
+}
+
+void dbg_before() {
+
+    assert(!dbg_show_mean);
+    dbg_show_hit_rate = true;
+    dbg_cnt0++;
+}
+
+void dbg_after() {
+
+    assert(!dbg_show_mean);
+    dbg_show_hit_rate = true;
+    dbg_cnt1++;
+}
+
+void dbg_mean_of(int v) {
+
+    assert(!dbg_show_hit_rate);
+    dbg_cnt0++;
+    dbg_cnt1 += v;
+}
+
 void dbg_print_hit_rate() {
 
   std::cout << "Total " << dbg_cnt0 << " Hit " << dbg_cnt1
index 49758bec7677dec604499bd0dd459197a3943393..9bdcc633289236f0376d1908f097ecd6dc6ddfef 100644 (file)
@@ -68,14 +68,11 @@ extern bool dbg_show_hit_rate;
 extern long dbg_cnt0;
 extern long dbg_cnt1;
 
-inline void dbg_hit_on(bool b) { dbg_show_hit_rate = true; dbg_cnt0++; if (b) dbg_cnt1++; }
-inline void dbg_hit_on_c(bool c, bool b) { if (c) dbg_hit_on(b); }
-
-inline void dbg_before() { dbg_show_hit_rate = true; dbg_cnt0++; }
-inline void dbg_after() { dbg_show_hit_rate = true; dbg_cnt1++; }
-
-inline void dbg_mean_of(int v) { dbg_cnt0++; dbg_cnt1 += v; }
-
+extern void dbg_hit_on(bool b);
+extern void dbg_hit_on_c(bool c, bool b);
+extern void dbg_before();
+extern void dbg_after();
+extern void dbg_mean_of(int v);
 extern void dbg_print_hit_rate();
 extern void dbg_print_mean();
 extern void dbg_print_hit_rate(std::ofstream& logFile);
index 8e6efb7a1bd9bdc50e041194f9a8c97b35fade5f..f80d5ccb496d527fa93922a8e060c220239cc706 100644 (file)
@@ -729,6 +729,12 @@ namespace {
 
     if (UseLogFile)
     {
+        if (dbg_show_mean)
+            dbg_print_mean(LogFile);
+
+        if (dbg_show_hit_rate)
+            dbg_print_hit_rate(LogFile);
+
         UndoInfo u;
         LogFile << "Nodes: " << nodes_searched() << std::endl
                 << "Nodes/second: " << nps() << std::endl