#include #include #include "counts.h" struct counts counts[MAX_COUNTS]; static void clear(struct counts *c) { *c = (struct counts) {0}; } void clear_all_counts(void) { for (int i = 0; i < MAX_COUNTS; i++) clear(counts+i); } void clear_accumulator(void) { clear(counts); } void add_counts(struct counts *target, struct counts *snapshot) { target->compare += counts[CURRENT].compare - snapshot->compare; target->rotate += counts[CURRENT].rotate - snapshot->rotate; target->swap += counts[CURRENT].swap - snapshot->swap; } void print_counts(void) { char *labels[] = {"total", "sortnet", "overlap", "merge", "move buffer", "distribute"}; for (int i = 0; i < MAX_COUNTS; i++) { const struct counts *c = counts+i; dprintf(42, "%12s: %10lu cmp, %10lu swap, %10lu rotate\n", labels[i], c->compare, c->swap, c->rotate); } }