More precise and complete A* performance statistics
Memory usage didn't include path (adp->path), neighbor cache (adp->neighbor_coords, adp->neighbor_nodes), and the hash table (adp->hashtab). While there, print path length. To get A* statistics on stderr, compile with AS_STATS defined.
This commit is contained in:
parent
c2628d43b7
commit
8f92fe40f4
1 changed files with 16 additions and 1 deletions
|
@ -31,8 +31,11 @@ as_stats(struct as_data *adp, FILE * fp)
|
||||||
int i;
|
int i;
|
||||||
int j;
|
int j;
|
||||||
int total_q;
|
int total_q;
|
||||||
|
int total_p;
|
||||||
int total_h;
|
int total_h;
|
||||||
|
size_t other;
|
||||||
struct as_queue *qp;
|
struct as_queue *qp;
|
||||||
|
struct as_path *pp;
|
||||||
struct as_hash *hp;
|
struct as_hash *hp;
|
||||||
|
|
||||||
fprintf(fp, "Statistics:\n");
|
fprintf(fp, "Statistics:\n");
|
||||||
|
@ -52,6 +55,10 @@ as_stats(struct as_data *adp, FILE * fp)
|
||||||
i++;
|
i++;
|
||||||
fprintf(fp, "\tsubsumed:\t%d\n", i);
|
fprintf(fp, "\tsubsumed:\t%d\n", i);
|
||||||
total_q += i;
|
total_q += i;
|
||||||
|
for (i = 0, pp = adp->path; pp; pp = pp->next)
|
||||||
|
i++;
|
||||||
|
total_p = i;
|
||||||
|
fprintf(fp, "path length: %d\n", total_p);
|
||||||
fprintf(fp, "hash table statistics (size %d):\n", adp->hashsize);
|
fprintf(fp, "hash table statistics (size %d):\n", adp->hashsize);
|
||||||
for (i = 0; i < adp->hashsize; i++) {
|
for (i = 0; i < adp->hashsize; i++) {
|
||||||
for (j = 0, hp = adp->hashtab[i]; hp; hp = hp->next)
|
for (j = 0, hp = adp->hashtab[i]; hp; hp = hp->next)
|
||||||
|
@ -64,10 +71,18 @@ as_stats(struct as_data *adp, FILE * fp)
|
||||||
fprintf(fp, "\tqueues\t%d\n",
|
fprintf(fp, "\tqueues\t%d\n",
|
||||||
(int)(total_q * sizeof(struct as_queue)));
|
(int)(total_q * sizeof(struct as_queue)));
|
||||||
fprintf(fp, "\tnodes\t%d\n", (int)(total_q * sizeof(struct as_node)));
|
fprintf(fp, "\tnodes\t%d\n", (int)(total_q * sizeof(struct as_node)));
|
||||||
|
fprintf(fp, "\tpath\t%d\n", (int)(total_p * sizeof(struct as_path)));
|
||||||
fprintf(fp, "\thash ents\t%d\n",
|
fprintf(fp, "\thash ents\t%d\n",
|
||||||
(int)(total_h * sizeof(struct as_hash)));
|
(int)(total_h * sizeof(struct as_hash)));
|
||||||
|
other = sizeof(struct as_data);
|
||||||
|
other += adp->maxneighbors * sizeof(struct as_coord);
|
||||||
|
other += (adp->maxneighbors + 1) * sizeof(struct as_node *);
|
||||||
|
other += adp->hashsize * sizeof(struct as_hash *);
|
||||||
|
fprintf(fp, "\tother\t%d\n", (int)other);
|
||||||
fprintf(fp, "\ttotal\t%d\n",
|
fprintf(fp, "\ttotal\t%d\n",
|
||||||
(int)(total_q * sizeof(struct as_queue) +
|
(int)(total_q * sizeof(struct as_queue) +
|
||||||
total_q * sizeof(struct as_node) +
|
total_q * sizeof(struct as_node) +
|
||||||
total_h * sizeof(struct as_hash)));
|
total_p * sizeof(struct as_path) +
|
||||||
|
total_h * sizeof(struct as_hash) +
|
||||||
|
other));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue