forked from dds-bridge/dds
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTimerList.cpp
More file actions
132 lines (103 loc) · 2.68 KB
/
Copy pathTimerList.cpp
File metadata and controls
132 lines (103 loc) · 2.68 KB
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/*
DDS, a bridge double dummy solver.
Copyright (C) 2006-2014 by Bo Haglund /
2014-2018 by Bo Haglund & Soren Hein.
See LICENSE and README.
*/
/*
See TimerList.h for some description.
*/
// #include <sstream>
// #include "dds.h"
#include "TimerList.h"
TimerList::TimerList()
{
TimerList::Reset();
}
TimerList::~TimerList()
{
}
void TimerList::Reset()
{
timerGroups.resize(TIMER_NO_SIZE);
timerGroups[TIMER_NO_AB].SetNames("AB");
timerGroups[TIMER_NO_MAKE].SetNames("Make");
timerGroups[TIMER_NO_UNDO].SetNames("Undo");
timerGroups[TIMER_NO_EVALUATE].SetNames("Evaluate");
timerGroups[TIMER_NO_NEXTMOVE].SetNames("NextMove");
timerGroups[TIMER_NO_QT].SetNames("QuickTricks");
timerGroups[TIMER_NO_LT].SetNames("LaterTricks");
timerGroups[TIMER_NO_MOVEGEN].SetNames("MoveGen");
timerGroups[TIMER_NO_LOOKUP].SetNames("Lookup");
timerGroups[TIMER_NO_BUILD].SetNames("Build");
}
void TimerList::Start(
const ABTimerType groupno,
const unsigned timerno)
{
if (groupno >= TIMER_NO_SIZE)
return;
timerGroups[groupno].Start(timerno);
}
void TimerList::End(
const ABTimerType groupno,
const unsigned timerno)
{
if (groupno >= TIMER_NO_SIZE)
return;
timerGroups[groupno].End(timerno);
}
bool TimerList::Used() const
{
for (unsigned g = 0; g < TIMER_NO_SIZE; g++)
{
if (timerGroups[g].Used())
return true;
}
return false;
}
void TimerList::PrintStats(ofstream& fout) const
{
if (! TimerList::Used())
return;
// Approximate the exclusive times of each function.
// The ABsearch*() functions are recursively nested,
// so subtract out the one below.
// The other ones are subtracted out based on knowledge
// of the functions.
TimerGroup ABGroup;
ABGroup = timerGroups[0];
ABGroup.Differentiate();
for (unsigned g = 1; g < TIMER_NO_SIZE; g++)
ABGroup -= timerGroups[g];
Timer ABTotal;
ABGroup.SetNames("AB");
ABGroup.Sum(ABTotal);
ABTotal.SetName("Sum");
Timer sumTotal = ABTotal;
for (unsigned g = 1; g < TIMER_NO_SIZE; g++)
{
Timer t;
timerGroups[g].Sum(t);
sumTotal += t;
}
fout << timerGroups[0].Header();
fout << ABGroup.SumLine(sumTotal);
for (unsigned g = 1; g < TIMER_NO_SIZE; g++)
fout << timerGroups[g].SumLine(sumTotal);
fout << timerGroups[0].DashLine();
fout << sumTotal.SumLine(sumTotal) << endl;
if (ABGroup.Used())
{
fout << ABGroup.Header();
fout << ABGroup.TimerLines(ABTotal);
fout << ABGroup.DashLine();
fout << ABTotal.SumLine(ABTotal) << endl;
}
#ifdef DDS_TIMING_DETAILS
fout << timerGroups[0].DetailHeader();
for (unsigned g = 0; g < TIMER_NO_SIZE; g++)
fout << timerGroups[g].DetailLines();
fout << endl;
#endif
}