Update codebase to remove clang warnings (and a couple of legit errors
[typhoon.git] / src / bench.c
1 /**
2
3 Copyright (c) Scott Gasch
4
5 Module Name:
6
7     bench.c
8
9 Abstract:
10
11     Engine speed benchmarking code.  This is the same test that crafty
12     uses to benchmark.
13
14 Author:
15
16     Scott Gasch ([email protected]) 28 Jun 2004
17
18 Revision History:
19
20     $Id: bench.c 345 2007-12-02 22:56:42Z scott $
21
22 **/
23
24 #include "chess.h"
25
26 COMMAND(BenchCommand)
27 /**
28
29 Routine description:
30
31     Run a benchmark
32
33 Parameters:
34
35     (hidden) CHAR *szInput
36     (hidden) ULONG argc
37     (hidden) CHAR *argv[]
38     (hidden) POSITION *pos
39
40 Return value:
41
42 **/
43 {
44     typedef struct _BENCH_NODE
45     {
46         CHAR *szFen;
47         ULONG uDepth;
48     }
49     BENCH_NODE;
50     static BENCH_NODE x[] = 
51     {
52         {
53             "3r1k2/4npp1/1ppr3p/p6P/P2PPPP1/1NR5/5K2/2R5 w - - 0 0", 11
54         },
55         {
56             "rnbqkb1r/p3pppp/1p6/2ppP3/3N4/2P5/PPP1QPPP/R1B1KB1R w KQkq - 0 0", 11
57         },
58         { 
59             "4b3/p3kp2/6p1/3pP2p/2pP1P2/4K1P1/P3N2P/8 w - - 0 0", 13
60         },
61         {
62             "r3r1k1/ppqb1ppp/8/4p1NQ/8/2P5/PP3PPP/R3R1K1 b - - 0 0", 11
63         },
64         {
65             "2r2rk1/1bqnbpp1/1p1ppn1p/pP6/N1P1P3/P2B1N1P/1B2QPP1/R2R2K1 b - - 0 0", 11
66         },
67         {
68             "r1bqk2r/pp2bppp/2p5/3pP3/P2Q1P2/2N1B3/1PP3PP/R4RK1 b kq - 0 0", 11
69         }
70     };
71     ULONG u;
72     double dStart;
73     double dEnd;
74     UINT64 u64Nodes = 0;
75
76 #ifdef DEBUG
77     Trace("You know this is a DEBUG build, right?\n");
78 #endif
79     dStart = SystemTimeStamp();
80     for (u = 0;
81          u < ARRAY_LENGTH(x) && (FALSE == g_fExitProgram);
82          u++)
83     {
84         VERIFY(PreGameReset(FALSE));
85         VERIFY(SetRootPosition(x[u].szFen));
86         pos = GetRootPosition();
87         g_Options.u64NodesSearched = 0ULL;
88         g_Options.uMaxDepth = x[u].uDepth;
89         Think(pos);
90         u64Nodes += g_Options.u64NodesSearched;
91     }
92     dEnd = SystemTimeStamp();
93     ASSERT(dStart < dEnd);
94     ASSERT(u64Nodes > 0);
95
96     Trace("Searched %"COMPILER_LONGLONG_UNSIGNED_FORMAT 
97           " nodes in %4.1f sec.\n", u64Nodes, (dEnd - dStart));
98     Trace("BENCHMARK>> %8.1f nodes/sec\n", (double)u64Nodes / (dEnd - dStart));
99     VERIFY(PreGameReset(TRUE));
100 }