3 * File name: ir/common/statistics.c
4 * Purpose: Compute statistics about firm library.
5 * Author: Goetz Lindenmaier
9 * Copyright: (c) 2004 Universität Karlsruhe
10 * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE.
13 #include "statistics.h"
19 /***********************************************************************/
20 /* Statistics about allocated datastructures: counts. */
22 static void count_nodes(ir_node *n, void *env) {
23 int * counter_ptr = (int *)env;
28 /** Prints number of irgraphs, number of nodes in them and
30 void print_graph_counts(int verbosity) {
31 int i, counter, total = 0;
32 int view = interprocedural_view;
33 ir_graph *old = current_ir_graph;
35 interprocedural_view = 0;
37 for (i = 0; i < get_irp_n_irgs(); i++) {
39 irg_walk_graph(get_irp_irg(i), count_nodes, NULL, &counter);
41 printf(" +%4d nodes in graph %s.\n", counter, get_entity_name(get_irg_entity(get_irp_irg(i))));
44 printf(" +++ There are %d graphs with total %d nodes.\n", get_irp_n_irgs(), total);
46 current_ir_graph = old;
47 interprocedural_view = view;
50 /** Prints number of types, number of entities and totals.
52 void print_type_counts(int verbosity) {
53 int i, counter, total = 0;
54 for (i = 0; i < get_irp_n_types(); i++) {
55 type *tp = get_irp_type(i);
57 if (is_class_type(tp)) counter = get_class_n_members(tp);
58 if (is_struct_type(tp)) counter = get_struct_n_members(tp);
59 if (is_union_type(tp)) counter = get_union_n_members(tp);
62 printf(" +%3d entities in %s type %s.\n", counter, get_type_tpop_name(tp), get_type_name(tp));
66 printf(" +++ There are %d types with total %d entities.\n", get_irp_n_types(), total);
67 printf(" +++ Global type has %d entities\n",
68 get_class_n_members(get_glob_type()));
72 /** Prints number of tarvals.
74 void print_tarval_counts(int verbosity) {
75 printf("tarval count not implemented.\n\n");
78 /** Prints number of idents.
80 void print_ident_counts(int verbosity) {
81 printf("ident count not implemented.\n\n");
85 void print_all_counts(int verbosity) {
86 printf(" +++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
87 print_graph_counts(verbosity);
88 printf(" +++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
89 print_type_counts(verbosity);
90 printf(" +++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
92 print_tarval_counts(verbosity);
93 printf(" +++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
94 print_ident_counts(verbosity);
95 printf(" +++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");