blob: d1f3910179fd07260a5021a678249449cf10071a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
#include <stdint.h>
#include <stdio.h>
#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);
}
}
|