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" |
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 |
|
|
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]); |
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 |
} |
} |
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 |
|
|
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 |
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 |
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 |
|
|