-
Notifications
You must be signed in to change notification settings - Fork 0
/
statistics.cpp
77 lines (68 loc) · 2.88 KB
/
statistics.cpp
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include "statistics.h"
#include <array>
#include <cassert>
#include <cinttypes>
#include <cstdio>
void Statistics::addFlush(FlushKind Kind) {
FlushCounter++;
Flushes[static_cast<int>(Kind)]++;
}
void Statistics::resetState() {
FlushCounter = 0;
for (unsigned i = 0; i < Flushes.size(); i++)
Flushes[i] = 0;
}
unsigned Statistics::getFlushCounter() const { return FlushCounter; };
void Statistics::dump() const {
#ifdef __APPLE__
printf("SingleRotation = %llu\n", Flushes[0]);
printf("DoubleRotation = %llu\n", Flushes[1]);
printf("Recolor = %llu\n", Flushes[2]);
printf("ColorFlip = %llu\n", Flushes[3]);
printf("NewNodeShort = %llu\n", Flushes[4]);
printf("InitializeVariables = %llu\n", Flushes[5]);
printf("FlushCommand = %llu\n", Flushes[6]);
printf("ShuffleIterators = %llu\n", Flushes[7]);
printf("UpdateRoot = %llu\n", Flushes[8]);
printf("Misc = %llu\n", Flushes[9]);
printf("RemoveNode = %llu\n", Flushes[10]);
printf("StateChange = %llu\n", Flushes[11]);
printf("Allocator = %llu\n", Flushes[12]);
printf("InsertNewNode = %llu\n", Flushes[13]);
printf("Loop = %llu\n", Flushes[14]);
printf("BalancePoints = %llu\n", Flushes[15]);
printf("BalanceFactors = %llu\n", Flushes[16]);
printf("Balance = %llu\n", Flushes[17]);
printf("FixParent = %llu\n", Flushes[18]);
printf("PushStack = %llu\n", Flushes[19]);
printf("PopStack = %llu\n", Flushes[20]);
#else
printf("SingleRotation = %lu\n", Flushes[0]);
printf("DoubleRotation = %lu\n", Flushes[1]);
printf("Recolor = %lu\n", Flushes[2]);
printf("ColorFlip = %lu\n", Flushes[3]);
printf("NewNodeShort = %lu\n", Flushes[4]);
printf("InitializeVariables = %lu\n", Flushes[5]);
printf("FlushCommand = %lu\n", Flushes[6]);
printf("ShuffleIterators = %lu\n", Flushes[7]);
printf("UpdateRoot = %lu\n", Flushes[8]);
printf("Misc = %lu\n", Flushes[9]);
printf("RemoveNode = %lu\n", Flushes[10]);
printf("StateChange = %lu\n", Flushes[11]);
printf("Allocator = %lu\n", Flushes[12]);
printf("InsertNewNode = %lu\n", Flushes[13]);
printf("Loop = %lu\n", Flushes[14]);
printf("BalancePoints = %lu\n", Flushes[15]);
printf("BalanceFactors = %lu\n", Flushes[16]);
printf("Balance = %lu\n", Flushes[17]);
printf("FixParent = %lu\n", Flushes[18]);
printf("PushStack = %lu\n", Flushes[19]);
printf("PopStack = %lu\n", Flushes[20]);
#endif
assert(Flushes.size() == 21);
uint64_t Sum = 0;
for (unsigned i = 0; i < Flushes.size(); i++)
Sum += Flushes[i];
printf("sum = %" PRIu64 "\n", Sum);
}
std::unique_ptr<Statistics> statistics;