mirror of
https://github.com/sockspls/badfish
synced 2025-04-29 16:23:09 +00:00
Simplify debug functions
No functional change. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
parent
93e539d909
commit
808a312e1c
4 changed files with 20 additions and 45 deletions
52
src/misc.cpp
52
src/misc.cpp
|
@ -39,12 +39,12 @@
|
||||||
# include <xmmintrin.h>
|
# include <xmmintrin.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <algorithm>
|
|
||||||
|
|
||||||
#include "bitcount.h"
|
#include "bitcount.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
|
@ -52,7 +52,6 @@
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
|
||||||
/// Version number. If Version is left empty, then Tag plus current
|
/// Version number. If Version is left empty, then Tag plus current
|
||||||
/// date (in the format YYMMDD) is used as a version number.
|
/// date (in the format YYMMDD) is used as a version number.
|
||||||
|
|
||||||
|
@ -93,43 +92,24 @@ const string engine_info(bool to_uci) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Debug stuff. Helper functions used mainly for debugging purposes
|
/// Debug functions used mainly to collect run-time statistics
|
||||||
|
|
||||||
static uint64_t dbg_hit_cnt0;
|
static uint64_t hits[2], means[2];
|
||||||
static uint64_t dbg_hit_cnt1;
|
|
||||||
static uint64_t dbg_mean_cnt0;
|
|
||||||
static uint64_t dbg_mean_cnt1;
|
|
||||||
|
|
||||||
void dbg_print_hit_rate() {
|
|
||||||
|
|
||||||
if (dbg_hit_cnt0)
|
|
||||||
cerr << "Total " << dbg_hit_cnt0 << " Hit " << dbg_hit_cnt1
|
|
||||||
<< " hit rate (%) " << 100 * dbg_hit_cnt1 / dbg_hit_cnt0 << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
void dbg_print_mean() {
|
|
||||||
|
|
||||||
if (dbg_mean_cnt0)
|
|
||||||
cerr << "Total " << dbg_mean_cnt0 << " Mean "
|
|
||||||
<< (float)dbg_mean_cnt1 / dbg_mean_cnt0 << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
void dbg_mean_of(int v) {
|
|
||||||
|
|
||||||
dbg_mean_cnt0++;
|
|
||||||
dbg_mean_cnt1 += v;
|
|
||||||
}
|
|
||||||
|
|
||||||
void dbg_hit_on(bool b) {
|
|
||||||
|
|
||||||
dbg_hit_cnt0++;
|
|
||||||
if (b)
|
|
||||||
dbg_hit_cnt1++;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
void dbg_hit_on(bool b) { hits[0]++; if (b) hits[1]++; }
|
||||||
void dbg_hit_on_c(bool c, bool b) { if (c) dbg_hit_on(b); }
|
void dbg_hit_on_c(bool c, bool b) { if (c) dbg_hit_on(b); }
|
||||||
void dbg_before() { dbg_hit_on(false); }
|
void dbg_mean_of(int v) { means[0]++; means[1] += v; }
|
||||||
void dbg_after() { dbg_hit_on(true); dbg_hit_cnt0--; }
|
|
||||||
|
void dbg_print() {
|
||||||
|
|
||||||
|
if (hits[0])
|
||||||
|
cerr << "Total " << hits[0] << " Hits " << hits[1]
|
||||||
|
<< " hit rate (%) " << 100 * hits[1] / hits[0] << endl;
|
||||||
|
|
||||||
|
if (means[0])
|
||||||
|
cerr << "Total " << means[0] << " Mean "
|
||||||
|
<< (float)means[1] / means[0] << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// system_time() returns the current system time, measured in milliseconds
|
/// system_time() returns the current system time, measured in milliseconds
|
||||||
|
|
|
@ -34,11 +34,8 @@ extern void prefetch(char* addr);
|
||||||
|
|
||||||
extern void dbg_hit_on(bool b);
|
extern void dbg_hit_on(bool b);
|
||||||
extern void dbg_hit_on_c(bool c, 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_mean_of(int v);
|
||||||
extern void dbg_print_hit_rate();
|
extern void dbg_print();
|
||||||
extern void dbg_print_mean();
|
|
||||||
|
|
||||||
class Position;
|
class Position;
|
||||||
extern Move move_from_uci(const Position& pos, const std::string& str);
|
extern Move move_from_uci(const Position& pos, const std::string& str);
|
||||||
|
|
|
@ -1974,9 +1974,7 @@ void do_timer_event() {
|
||||||
if (system_time() - lastInfoTime >= 1000 || !lastInfoTime)
|
if (system_time() - lastInfoTime >= 1000 || !lastInfoTime)
|
||||||
{
|
{
|
||||||
lastInfoTime = system_time();
|
lastInfoTime = system_time();
|
||||||
|
dbg_print();
|
||||||
dbg_print_mean();
|
|
||||||
dbg_print_hit_rate();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Limits.ponder)
|
if (Limits.ponder)
|
||||||
|
|
|
@ -176,10 +176,10 @@ void ThreadsManager::init() {
|
||||||
threads[i].threadID = i;
|
threads[i].threadID = i;
|
||||||
|
|
||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
threads[i].handle = CreateThread(NULL, 0, start_routine, (LPVOID)&threads[i], 0, NULL);
|
threads[i].handle = CreateThread(NULL, 0, start_routine, &threads[i], 0, NULL);
|
||||||
bool ok = (threads[i].handle != NULL);
|
bool ok = (threads[i].handle != NULL);
|
||||||
#else
|
#else
|
||||||
bool ok = !pthread_create(&threads[i].handle, NULL, start_routine, (void*)&threads[i]);
|
bool ok = !pthread_create(&threads[i].handle, NULL, start_routine, &threads[i]);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!ok)
|
if (!ok)
|
||||||
|
|
Loading…
Add table
Reference in a new issue