perft-test: improve displayed info, add selective tests
- print total #tests, #tests to do and VERSION string - add starting point for tests, and #tests to run
This commit is contained in:
10
Makefile
10
Makefile
@@ -126,7 +126,7 @@ else # ifeq ($(build),dev)
|
|||||||
# fen.c
|
# fen.c
|
||||||
#CPPFLAGS += -DDEBUG_FEN # FEN decoding
|
#CPPFLAGS += -DDEBUG_FEN # FEN decoding
|
||||||
# hash / TT
|
# hash / TT
|
||||||
#CPPFLAGS += -DZOBRIST_VERIFY # double chk zobrist
|
CPPFLAGS += -DZOBRIST_VERIFY # double chk zobrist
|
||||||
#CPPFLAGS += -DPERFT_MOVE_HISTORY # perft, keep prev moves
|
#CPPFLAGS += -DPERFT_MOVE_HISTORY # perft, keep prev moves
|
||||||
# attack.c
|
# attack.c
|
||||||
#CPPFLAGS += -DDEBUG_ATTACK_ATTACKERS # sq_attackers
|
#CPPFLAGS += -DDEBUG_ATTACK_ATTACKERS # sq_attackers
|
||||||
@@ -229,16 +229,16 @@ else
|
|||||||
all: libs testing $(TARGET)
|
all: libs testing $(TARGET)
|
||||||
|
|
||||||
release:
|
release:
|
||||||
$(MAKE) BUILD=release clean all
|
$(MAKE) build=release clean all
|
||||||
|
|
||||||
dev:
|
dev:
|
||||||
$(MAKE) BUILD=dev clean all
|
$(MAKE) build=dev clean all
|
||||||
|
|
||||||
perf:
|
perf:
|
||||||
$(MAKE) BUILD=perf clean all
|
$(MAKE) build=perf clean all
|
||||||
|
|
||||||
debug:
|
debug:
|
||||||
$(MAKE) BUILD=debug clean all
|
$(MAKE) build=debug clean all
|
||||||
|
|
||||||
compile: brlib objs
|
compile: brlib objs
|
||||||
|
|
||||||
|
@@ -451,7 +451,12 @@ struct fentest {
|
|||||||
|
|
||||||
static int fentest_cur = -1;
|
static int fentest_cur = -1;
|
||||||
|
|
||||||
static char *next_fen(uint module)
|
static __unused void restart_fen(void)
|
||||||
|
{
|
||||||
|
fentest_cur = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static __unused char *next_fen(uint module)
|
||||||
{
|
{
|
||||||
fentest_cur++;
|
fentest_cur++;
|
||||||
|
|
||||||
|
@@ -242,7 +242,9 @@ static int usage(char *prg)
|
|||||||
fprintf(stderr, "Usage: %s [-cms][-d depth] [-p version] [-t size:\n", prg);
|
fprintf(stderr, "Usage: %s [-cms][-d depth] [-p version] [-t size:\n", prg);
|
||||||
fprintf(stderr, "\t-c: do *not* print FEN comments\n");
|
fprintf(stderr, "\t-c: do *not* print FEN comments\n");
|
||||||
fprintf(stderr, "\t-d depth: perft depth (default: 6)\n");
|
fprintf(stderr, "\t-d depth: perft depth (default: 6)\n");
|
||||||
|
fprintf(stderr, "\t-l line: start from 'line' test\n");
|
||||||
fprintf(stderr, "\t-m: print moves details\n");
|
fprintf(stderr, "\t-m: print moves details\n");
|
||||||
|
fprintf(stderr, "\t-n number: do 'number' tests (default: all)\n");
|
||||||
fprintf(stderr, "\t-s: use Stockfish to validate perft result\n");
|
fprintf(stderr, "\t-s: use Stockfish to validate perft result\n");
|
||||||
fprintf(stderr, "\t-t size: Transposition Table size (Mb). Default: 32\n");
|
fprintf(stderr, "\t-t size: Transposition Table size (Mb). Default: 32\n");
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
@@ -252,7 +254,7 @@ static int usage(char *prg)
|
|||||||
|
|
||||||
int main(int ac, char**av)
|
int main(int ac, char**av)
|
||||||
{
|
{
|
||||||
int curtest = 0;
|
int curtest = 0, totalfen = 0;
|
||||||
u64 sf_count = 0, my_count;
|
u64 sf_count = 0, my_count;
|
||||||
bool comment = true, sf_run = false, divide = false;
|
bool comment = true, sf_run = false, divide = false;
|
||||||
char *fen;
|
char *fen;
|
||||||
@@ -262,6 +264,8 @@ int main(int ac, char**av)
|
|||||||
FILE *outfd = NULL;
|
FILE *outfd = NULL;
|
||||||
s64 ms, lps;
|
s64 ms, lps;
|
||||||
int opt, depth = 6, run = 3, tt, newtt = HASH_SIZE_DEFAULT;
|
int opt, depth = 6, run = 3, tt, newtt = HASH_SIZE_DEFAULT;
|
||||||
|
int startline = 1, ntests = INT_MAX;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
s64 count, countskipped, ms;
|
s64 count, countskipped, ms;
|
||||||
s64 minlps, maxlps;
|
s64 minlps, maxlps;
|
||||||
@@ -273,7 +277,8 @@ int main(int ac, char**av)
|
|||||||
{ .minlps = LONG_MAX },
|
{ .minlps = LONG_MAX },
|
||||||
};
|
};
|
||||||
|
|
||||||
while ((opt = getopt(ac, av, "cd:mp:st:")) != -1) {
|
printf("Perft " VERSION "\n");
|
||||||
|
while ((opt = getopt(ac, av, "cd:l:mn:p:st:")) != -1) {
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
case 'c':
|
case 'c':
|
||||||
comment = false;
|
comment = false;
|
||||||
@@ -283,9 +288,15 @@ int main(int ac, char**av)
|
|||||||
if (depth <= 0)
|
if (depth <= 0)
|
||||||
depth = 6;
|
depth = 6;
|
||||||
break;
|
break;
|
||||||
|
case 'l':
|
||||||
|
startline = atoi(optarg);
|
||||||
|
break;
|
||||||
case 'm':
|
case 'm':
|
||||||
divide = true;
|
divide = true;
|
||||||
break;
|
break;
|
||||||
|
case 'n':
|
||||||
|
ntests = atoi(optarg);
|
||||||
|
break;
|
||||||
case 'p':
|
case 'p':
|
||||||
run = atoi(optarg);
|
run = atoi(optarg);
|
||||||
break;
|
break;
|
||||||
@@ -325,14 +336,23 @@ int main(int ac, char**av)
|
|||||||
if (sf_run)
|
if (sf_run)
|
||||||
outfd = open_stockfish();
|
outfd = open_stockfish();
|
||||||
|
|
||||||
|
/* count total fen tests we will do */
|
||||||
|
while (next_fen(PERFT | MOVEDO))
|
||||||
|
totalfen++;
|
||||||
|
restart_fen();
|
||||||
|
|
||||||
CLOCK_DEFINE(clock, CLOCK_MONOTONIC);
|
CLOCK_DEFINE(clock, CLOCK_MONOTONIC);
|
||||||
while ((fen = next_fen(PERFT | MOVEDO))) {
|
while ((fen = next_fen(PERFT | MOVEDO))) {
|
||||||
|
if (cur_line() < startline)
|
||||||
|
continue;
|
||||||
|
if (curtest >= ntests)
|
||||||
|
break;
|
||||||
if (!(fenpos = fen2pos(pos, fen))) {
|
if (!(fenpos = fen2pos(pos, fen))) {
|
||||||
printf("wrong fen line:%d fen:%s\n\n", cur_line(), fen);
|
printf("wrong fen line:%d fen:%s\n\n", cur_line(), fen);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
curtest++;
|
curtest++;
|
||||||
printf("test:%d line:%d fen:%s\n", curtest, cur_line(), fen);
|
printf("test:%d/%d line:%d fen:%s\n", curtest, totalfen, cur_line(), fen);
|
||||||
if (comment)
|
if (comment)
|
||||||
printf("\t\"%s\"\n",
|
printf("\t\"%s\"\n",
|
||||||
*cur_comment()? cur_comment(): "no test desc");
|
*cur_comment()? cur_comment(): "no test desc");
|
||||||
|
Reference in New Issue
Block a user