9 #include "buildFacade.h"
11 /* only for getTime() */
13 #include <sys/resource.h>
15 /* macro to detect and to notify errors */
16 #define IFERROR(error) {{if (error) { fprintf(stderr, "%s\n", error_index(error)); exit(1); }}}
21 double getTime (void);
22 void usage(char * progname);
24 static void *Index; /* opauque data type */
25 static ulong Index_size, Text_length;
26 static double Load_time;
31 * Temporary usage: run_queries <index file> <type> [length] [V]
33 int main (int argc, char *argv[])
46 printf("\n Stats of index: %s\n",argv[1]);
48 Load_time = getTime ();
49 error = load_index (filename, &Index);
51 Load_time = getTime () - Load_time;
52 fprintf (stderr, "\tLoad index time = %.2f secs\n", Load_time);
54 error = index_size(Index, &Index_size);
57 error = get_length(Index, &Text_length);
62 error = get_length(Index, &text_len);
65 error = printInfo(Index);
68 error = free_index(Index);
73 fprintf(stdout,"\t===============================================\n");
74 fprintf(stdout,"\tInput: %lu bytes (text) --> Output %lu bytes (wcsa).\n", text_len, Index_size);
75 fprintf(stderr,"\tIndex size = %lu Kb\n", Index_size/1024);
76 fprintf(stdout,"\tOverall compression --> %.2f%% (%.2f bits per char).\n",
77 (100.0*Index_size)/text_len, (Index_size*8.0)/text_len);
78 fprintf(stdout,"\t===============================================\n");
87 double usertime, systime;
90 getrusage (RUSAGE_SELF, &usage);
92 usertime = (double) usage.ru_utime.tv_sec +
93 (double) usage.ru_utime.tv_usec / 1000000.0;
95 systime = (double) usage.ru_stime.tv_sec +
96 (double) usage.ru_stime.tv_usec / 1000000.0;
98 //return (usertime + systime);
103 void usage(char * progname) {
104 fprintf(stderr, "\nThe program loads <index> and shows some stats on it\n");
105 fprintf(stderr, "Usage: %s <index> \n", progname);