perft-test: option to run perft/perft2/both
This commit is contained in:
@@ -233,11 +233,17 @@ int main(int __unused ac, __unused char**av)
|
|||||||
//move_t move;
|
//move_t move;
|
||||||
FILE *outfd;
|
FILE *outfd;
|
||||||
int depth = 6;
|
int depth = 6;
|
||||||
|
s64 ms1 = 0, ms1_total = 0, ms2 = 0, ms2_total = 0;
|
||||||
|
int run = 3;
|
||||||
|
|
||||||
if (ac > 1)
|
if (ac > 1)
|
||||||
depth = atoi(av[1]);
|
depth = atoi(av[1]);
|
||||||
printf("depth = %d\n", depth);
|
if (ac > 2)
|
||||||
|
run = atoi(av[2]);
|
||||||
|
printf("depth = %d run=%d\n", depth, run);
|
||||||
|
|
||||||
|
if (!run)
|
||||||
|
exit(0);
|
||||||
setlocale(LC_NUMERIC, "");
|
setlocale(LC_NUMERIC, "");
|
||||||
setlinebuf(stdout); /* line-buffered stdout */
|
setlinebuf(stdout); /* line-buffered stdout */
|
||||||
outfd = open_stockfish();
|
outfd = open_stockfish();
|
||||||
@@ -245,6 +251,8 @@ int main(int __unused ac, __unused char**av)
|
|||||||
bitboard_init();
|
bitboard_init();
|
||||||
hyperbola_init();
|
hyperbola_init();
|
||||||
|
|
||||||
|
|
||||||
|
CLOCK_DEFINE(clock, CLOCK_PROCESS);
|
||||||
while ((fen = next_fen(PERFT | MOVEDO))) {
|
while ((fen = next_fen(PERFT | MOVEDO))) {
|
||||||
test_line = cur_line();
|
test_line = cur_line();
|
||||||
if (!(pos = fen2pos(NULL, fen))) {
|
if (!(pos = fen2pos(NULL, fen))) {
|
||||||
@@ -256,35 +264,46 @@ int main(int __unused ac, __unused char**av)
|
|||||||
savepos = pos_dup(pos);
|
savepos = pos_dup(pos);
|
||||||
//int j = 0;
|
//int j = 0;
|
||||||
|
|
||||||
s64 μs;
|
if (run & 1) {
|
||||||
CLOCK_DEFINE(clock, CLOCK_SYSTEM);
|
clock_start(&clock);
|
||||||
|
my_count = perft(pos, depth, 1);
|
||||||
|
ms1 = clock_elapsed_ms(&clock);
|
||||||
|
ms1_total += ms1;
|
||||||
|
|
||||||
clock_start(&clock);
|
if (sf_count == my_count) {
|
||||||
my_count = perft(pos, depth, 1);
|
printf("pt1 OK : line=%03d perft=%lu %'ldms lps=%'lu \"%s\"\n",
|
||||||
μs = clock_elapsed_μs(&clock);
|
test_line, my_count, ms1,
|
||||||
|
ms1? my_count*1000l/ms1: 0,
|
||||||
if (sf_count == my_count) {
|
fen);
|
||||||
printf("pt1 OK : line=%03d perft=%lu μs=%'ldms lps=%'lu \"%s\"\n",
|
} else {
|
||||||
test_line, my_count, μs, my_count*1000000l/μs, fen);
|
printf("pt1 ERR: line=%03d sf=%lu me=%lu \"%s\"\n",
|
||||||
} else {
|
test_line, sf_count, my_count, fen);
|
||||||
printf("pt1 ERR: line=%03d sf=%lu me=%lu \"%s\"\n",
|
}
|
||||||
test_line, sf_count, my_count, fen);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
clock_start(&clock);
|
if (run & 2) {
|
||||||
my_count = perft2(pos, depth, 1);
|
clock_start(&clock);
|
||||||
μs = clock_elapsed_μs(&clock);
|
my_count = perft2(pos, depth, 1);
|
||||||
|
ms2 = clock_elapsed_ms(&clock);
|
||||||
|
ms2_total += ms2;
|
||||||
|
|
||||||
if (sf_count == my_count) {
|
if (sf_count == my_count) {
|
||||||
printf("pt2 OK : line=%03d perft=%lu μs=%'ldms lps=%'lu \"%s\"\n\n",
|
printf("pt2 OK : line=%03d perft=%lu %'ldms lps=%'lu \"%s\"\n\n",
|
||||||
test_line, my_count, μs, my_count*1000000l/μs, fen);
|
test_line, my_count, ms2,
|
||||||
} else {
|
ms2? my_count*1000l/ms2: 0,
|
||||||
printf("pt2 ERR: line=%03d sf=%lu me=%lu \"%s\"\n\n",
|
fen);
|
||||||
test_line, sf_count, my_count, fen);
|
} else {
|
||||||
|
printf("pt2 ERR: line=%03d sf=%lu me=%lu \"%s\"\n\n",
|
||||||
|
test_line, sf_count, my_count, fen);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
pos_del(savepos);
|
pos_del(savepos);
|
||||||
pos_del(pos);
|
pos_del(pos);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
if (run & 1)
|
||||||
|
printf("total perft %'ldms\n", ms1_total);
|
||||||
|
if (run & 2)
|
||||||
|
printf("total perft2 %'ldms\n", ms2_total);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user