2 * A* Search - A search library used in Empire to determine paths between
4 * Copyright (C) 1990-1998 Phil Lapsley
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 * Print statistics on algorithm performance to the file pointer "fp".
29 as_stats(struct as_data *adp, FILE * fp)
41 fprintf(fp, "Statistics:\n");
43 fprintf(fp, "queue lengths:\n");
46 for (i = 0, qp = adp->head; qp; qp = qp->next)
48 fprintf(fp, "\tmain:\t%d\n", i);
50 for (i = 0, qp = adp->tried; qp; qp = qp->next)
52 fprintf(fp, "\ttried:\t%d\n", i);
54 for (i = 0, qp = adp->subsumed; qp; qp = qp->next)
56 fprintf(fp, "\tsubsumed:\t%d\n", i);
58 for (i = 0, pp = adp->path; pp; pp = pp->next)
61 fprintf(fp, "path length: %d\n", total_p);
62 fprintf(fp, "hash table statistics (size %d):\n", adp->hashsize);
63 for (i = 0; i < adp->hashsize; i++) {
64 for (j = 0, hp = adp->hashtab[i]; hp; hp = hp->next)
66 fprintf(fp, "\t%d\t%d\n", i, j);
69 fprintf(fp, "\ttotal\t%d\n", total_h);
70 fprintf(fp, "approximate memory usage (bytes):\n");
71 fprintf(fp, "\tqueues\t%d\n",
72 (int)(total_q * sizeof(struct as_queue)));
73 fprintf(fp, "\tnodes\t%d\n", (int)(total_q * sizeof(struct as_node)));
74 fprintf(fp, "\tpath\t%d\n", (int)(total_p * sizeof(struct as_path)));
75 fprintf(fp, "\thash ents\t%d\n",
76 (int)(total_h * sizeof(struct as_hash)));
77 other = sizeof(struct as_data);
78 other += adp->maxneighbors * sizeof(struct as_coord);
79 other += (adp->maxneighbors + 1) * sizeof(struct as_node *);
80 other += adp->hashsize * sizeof(struct as_hash *);
81 fprintf(fp, "\tother\t%d\n", (int)other);
82 fprintf(fp, "\ttotal\t%d\n",
83 (int)(total_q * sizeof(struct as_queue) +
84 total_q * sizeof(struct as_node) +
85 total_p * sizeof(struct as_path) +
86 total_h * sizeof(struct as_hash) +