Bool transition: do not scanf directly into would-be bools.
[gnushogi.git] / gnushogi / sizetest.c
blob91dd0ef8aabece56a21acbbf7143856e02c9a878
1 /*
2 * FILE: sizetest.c
4 * Display memory usage of GNU Shogi data structures.
6 * ----------------------------------------------------------------------
7 * Copyright (c) 1993, 1994, 1995 Matthias Mutz
8 * Copyright (c) 1999 Michael Vanier and the Free Software Foundation
9 * Copyright (c) 2008, 2013, 2014 Yann Dirson and the Free Software Foundation
11 * GNU SHOGI is based on GNU CHESS
13 * Copyright (c) 1988, 1989, 1990 John Stanback
14 * Copyright (c) 1992 Free Software Foundation
16 * This file is part of GNU SHOGI.
18 * GNU Shogi is free software; you can redistribute it and/or modify it
19 * under the terms of the GNU General Public License as published by the
20 * Free Software Foundation; either version 3 of the License,
21 * or (at your option) any later version.
23 * GNU Shogi is distributed in the hope that it will be useful, but WITHOUT
24 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
25 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
26 * for more details.
28 * You should have received a copy of the GNU General Public License along
29 * with GNU Shogi; see the file COPYING. If not, see
30 * <http://www.gnu.org/licenses/>.
31 * ----------------------------------------------------------------------
35 #include "gnushogi.h"
37 /*unsigned*/ short rehash; /* -1 is used as a flag --tpm */
39 int
40 main(int argc, char **argv)
42 long l;
43 int n;
45 #if ttblsz
46 l = (long)sizeof(struct hashentry);
47 n = (int)((l * (ttblsz + rehash) * 2) / 1000);
48 printf("ttable:\t\t%4d\tkByte\t[hashentry:%ld "
49 "* (ttblsz:%d + rehash:%d) * 2]\n",
50 n, l, ttblsz, rehash);
51 #endif
53 #if defined CACHE
54 l = (long)sizeof(struct etable);
55 n = (int)((l * (size_t)ETABLE) / 1000);
56 #else
57 l = n = 0;
58 #endif
60 printf("etab:\t\t%4d\tkByte\t[etable:%ld ETABLE:%d]\n",
61 n, l, ETABLE);
63 l = (long)sizeof(struct leaf);
64 n = (int)(l * TREE / 1000);
65 printf("Tree:\t\t%4d\tkByte\t[leaf:%ld * TREE:%d]\n",
66 n, l, TREE);
68 #if defined HISTORY
69 n = (int)(sizeof_history / 1000);
70 #else
71 n = 0;
72 #endif
74 printf("history:\t%4d\tkByte\t[unsigned short:%lu "
75 "* HISTORY_SIZE:%ld]\n",
76 n, sizeof(unsigned short), (long)HISTORY_SIZE);
78 #ifndef SAVE_NEXTPOS
79 l = (long)sizeof(next_array);
80 n = (int)((l * NO_PTYPE_PIECES) / 1000);
82 printf("nextpos:\t%4d\tkByte\t[next_array:%ld "
83 "* NO_PTYPE_PIECES:%d]\n",
84 n, l, NO_PTYPE_PIECES);
86 l = (long)sizeof(next_array);
87 n = (int)((l * NO_PTYPE_PIECES) / 1000);
88 printf("nextdir:\t%4d\tkByte\t[next_array:%ld "
89 "* NO_PTYPE_PIECES:%d]\n",
90 n, l, NO_PTYPE_PIECES);
91 #endif
93 #ifndef SAVE_DISTDATA
94 n = (int)(sizeof(distdata_array) / 1000);
95 printf("distdata:\t%4d\tkByte\n", n);
96 #endif
98 #ifndef SAVE_PTYPE_DISTDATA
99 l = (long)sizeof(distdata_array);
100 n = (int)((l * NO_PTYPE_PIECES) / 1000);
101 printf("ptype_distdata:\t%4d\tkByte\t[distdata_array:%ld "
102 "* NO_PTYPE_PIECES:%d]\n",
103 n, l, NO_PTYPE_PIECES);
104 #endif
106 l = (long)sizeof(hashcode_array);
107 n = (int)(l / 1000);
108 printf("hashcode:\t%4d\tkByte\t[hashval:%ld]\n",
109 n, (long)sizeof(struct hashval));
111 l = (long)sizeof(drop_hashcode_array);
112 n = (int)(l / 1000);
113 printf("drop_hashcode:\t%4d\tkByte\t[hashval:%ld]\n",
114 n, (long)sizeof(struct hashval));
116 l = (long)sizeof(value_array);
117 n = (int)(l / 1000);
118 printf("value:\t\t%4d\tkByte\n", n);
120 l = (long)sizeof(fscore_array);
121 n = (int)(l / 1000);
122 printf("fscore:\t\t%4d\tkByte\n", n);
124 return 0;