/[bison]/bison/lib/bitset_stats.c
ViewVC logotype

Diff of /bison/lib/bitset_stats.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by akim, Tue Jul 2 13:51:26 2002 UTC revision 1.2 by eggert, Mon Aug 12 14:16:49 2002 UTC
# Line 38  Line 38 
38  #include <string.h>  #include <string.h>
39  #include <stdio.h>  #include <stdio.h>
40    
41    #include "gettext.h"
42    #define _(Msgid)  gettext (Msgid)
43    
44  /* Configuration macros.  */  /* Configuration macros.  */
45  #define BITSET_STATS_FILE "bitset.dat"  #define BITSET_STATS_FILE "bitset.dat"
# Line 221  bitset_stats_print_1 (file, name, stats) Line 223  bitset_stats_print_1 (file, name, stats)
223      return;      return;
224        
225    fprintf (file, "%s:\n", name);    fprintf (file, "%s:\n", name);
226    fprintf (file, "%d bitset_allocs, %d freed (%.2f%%).\n",    fprintf (file, _("%d bitset_allocs, %d freed (%.2f%%).\n"),
227             stats->allocs, stats->frees,             stats->allocs, stats->frees,
228             stats->allocs ? 100.0 * stats->frees / stats->allocs : 0);             stats->allocs ? 100.0 * stats->frees / stats->allocs : 0);
229    fprintf (file, "%d bitset_sets, %d cached (%.2f%%)\n",    fprintf (file, _("%d bitset_sets, %d cached (%.2f%%)\n"),
230             stats->sets, stats->cache_sets,             stats->sets, stats->cache_sets,
231             stats->sets ? 100.0 * stats->cache_sets / stats->sets : 0);             stats->sets ? 100.0 * stats->cache_sets / stats->sets : 0);
232    fprintf (file, "%d bitset_resets, %d cached (%.2f%%)\n",    fprintf (file, _("%d bitset_resets, %d cached (%.2f%%)\n"),
233             stats->resets, stats->cache_resets,             stats->resets, stats->cache_resets,
234             stats->resets ? 100.0 * stats->cache_resets / stats->resets : 0);             stats->resets ? 100.0 * stats->cache_resets / stats->resets : 0);
235    fprintf (file, "%d bitset_tests, %d cached (%.2f%%)\n",    fprintf (file, _("%d bitset_tests, %d cached (%.2f%%)\n"),
236             stats->tests, stats->cache_tests,             stats->tests, stats->cache_tests,
237             stats->tests ? 100.0 * stats->cache_tests / stats->tests : 0);             stats->tests ? 100.0 * stats->cache_tests / stats->tests : 0);
238    
239    fprintf (file, "%d bitset_lists\n", stats->lists);    fprintf (file, _("%d bitset_lists\n"), stats->lists);
240    
241    bitset_log_histogram_print (file, name, "count log histogram\n",    bitset_log_histogram_print (file, name, _("count log histogram\n"),
242                                BITSET_LOG_COUNT_BINS, stats->list_counts);                                BITSET_LOG_COUNT_BINS, stats->list_counts);
243    
244    bitset_log_histogram_print (file, name, "size log histogram\n",    bitset_log_histogram_print (file, name, _("size log histogram\n"),
245                                BITSET_LOG_SIZE_BINS, stats->list_sizes);                                BITSET_LOG_SIZE_BINS, stats->list_sizes);
246    
247    bitset_percent_histogram_print (file, name, "density histogram\n",    bitset_percent_histogram_print (file, name, _("density histogram\n"),
248                                    BITSET_DENSITY_BINS, stats->list_density);                                    BITSET_DENSITY_BINS, stats->list_density);
249  }  }
250    
# Line 259  bitset_stats_print (file, verbose) Line 261  bitset_stats_print (file, verbose)
261    if (!bitset_stats_info)    if (!bitset_stats_info)
262      return;      return;
263    
264    fprintf (file, "Bitset statistics:\n\n");    fprintf (file, _("Bitset statistics:\n\n"));
265    
266    if (bitset_stats_info->runs > 1)    if (bitset_stats_info->runs > 1)
267      fprintf (file, "Accumulated runs = %d\n", bitset_stats_info->runs);      fprintf (file, _("Accumulated runs = %d\n"), bitset_stats_info->runs);
268    
269    for (i = 0; i < BITSET_TYPE_NUM; i++)    for (i = 0; i < BITSET_TYPE_NUM; i++)
270      bitset_stats_print_1 (file, names[i], &bitset_stats_info->types[i]);      bitset_stats_print_1 (file, names[i], &bitset_stats_info->types[i]);
# Line 306  bitset_stats_read (filename) Line 308  bitset_stats_read (filename)
308                   1, file) != 1)                   1, file) != 1)
309          {          {
310            if (ferror (file))            if (ferror (file))
311              perror ("Could not read stats file.");              perror (_("Could not read stats file."));
312            else            else
313              fprintf (stderr, "Bad stats file size.\n");              fprintf (stderr, _("Bad stats file size.\n"));
314          }          }
315        fclose (file);        fclose (file);
316      }      }
# Line 334  bitset_stats_write (filename) Line 336  bitset_stats_write (filename)
336      {      {
337        if (fwrite (&bitset_stats_info_data, sizeof (bitset_stats_info_data),        if (fwrite (&bitset_stats_info_data, sizeof (bitset_stats_info_data),
338                    1, file) != 1)                    1, file) != 1)
339          perror ("Could not write stats file.");          perror (_("Could not write stats file."));
340        fclose (file);        fclose (file);
341      }      }
342    else    else
343      perror ("Could not open stats file for writing.");      perror (_("Could not open stats file for writing."));
344  }  }
345    
346    
# Line 365  bitset_stats_set (dst, bitno) Line 367  bitset_stats_set (dst, bitno)
367       bitset_bindex bitno;       bitset_bindex bitno;
368  {  {
369    bitset bset = dst->s.bset;    bitset bset = dst->s.bset;
370    bitset_windex index = bitno / BITSET_WORD_BITS;    bitset_windex wordno = bitno / BITSET_WORD_BITS;
371    bitset_windex offset = index - bset->b.cindex;    bitset_windex offset = wordno - bset->b.cindex;
372        
373    BITSET_STATS_SETS_INC (bset);    BITSET_STATS_SETS_INC (bset);
374    
375    if (offset < bset->b.csize)    if (offset < bset->b.csize)
376      {      {
377        bset->b.cdata[offset] |= (1 << (bitno % BITSET_WORD_BITS));        bset->b.cdata[offset] |= (bitset_word) 1 << (bitno % BITSET_WORD_BITS);
378        BITSET_STATS_CACHE_SETS_INC (bset);        BITSET_STATS_CACHE_SETS_INC (bset);
379      }      }
380    else    else
# Line 386  bitset_stats_reset (dst, bitno) Line 388  bitset_stats_reset (dst, bitno)
388       bitset_bindex bitno;       bitset_bindex bitno;
389  {  {
390    bitset bset = dst->s.bset;    bitset bset = dst->s.bset;
391    bitset_windex index = bitno / BITSET_WORD_BITS;    bitset_windex wordno = bitno / BITSET_WORD_BITS;
392    bitset_windex offset = index - bset->b.cindex;    bitset_windex offset = wordno - bset->b.cindex;
393        
394    BITSET_STATS_RESETS_INC (bset);    BITSET_STATS_RESETS_INC (bset);
395    
396    if (offset < bset->b.csize)    if (offset < bset->b.csize)
397      {      {
398        bset->b.cdata[offset] &= ~(1 << (bitno % BITSET_WORD_BITS));        bset->b.cdata[offset] &=
399            ~((bitset_word) 1 << (bitno % BITSET_WORD_BITS));
400        BITSET_STATS_CACHE_RESETS_INC (bset);        BITSET_STATS_CACHE_RESETS_INC (bset);
401      }      }
402    else    else
# Line 407  bitset_stats_test (src, bitno) Line 410  bitset_stats_test (src, bitno)
410       bitset_bindex bitno;       bitset_bindex bitno;
411  {  {
412    bitset bset = src->s.bset;    bitset bset = src->s.bset;
413    bitset_windex index = bitno / BITSET_WORD_BITS;    bitset_windex wordno = bitno / BITSET_WORD_BITS;
414    bitset_windex offset = index - bset->b.cindex;    bitset_windex offset = wordno - bset->b.cindex;
415    
416    BITSET_STATS_TESTS_INC (bset);    BITSET_STATS_TESTS_INC (bset);
417        

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26