blob: ca7fb8b1ce2e4836ded3fdc5b312f3026ed5b114 (
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
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
|
/******************************************************************************
* Top contributors (to current version):
* Tim King, Morgan Deters, Mathias Preiner
*
* This file is part of the cvc5 project.
*
* Copyright (c) 2009-2021 by the authors listed in the file AUTHORS
* in the top-level source directory and their institutional affiliations.
* All rights reserved. See the file COPYING in the top-level source
* directory for licensing information.
* ****************************************************************************
*
* Statistics utility classes
*/
#include "util/statistics_registry.h"
#include <cstdlib>
#include <iostream>
#include "base/check.h"
#include "lib/clock_gettime.h"
#include "util/ostream_util.h"
#ifdef CVC5_STATISTICS_ON
#define CVC5_USE_STATISTICS true
#else
#define CVC5_USE_STATISTICS false
#endif
/****************************************************************************/
/* Some utility functions for timespec */
/****************************************************************************/
namespace cvc5 {
void StatisticsRegistry::registerStat(Stat* s)
{
#ifdef CVC5_STATISTICS_ON
PrettyCheckArgument(
d_stats.find(s) == d_stats.end(),
s,
"Statistic `%s' is already registered with this registry.",
s->getName().c_str());
d_stats.insert(s);
#endif /* CVC5_STATISTICS_ON */
}/* StatisticsRegistry::registerStat_() */
void StatisticsRegistry::unregisterStat(Stat* s)
{
#ifdef CVC5_STATISTICS_ON
AlwaysAssert(s != nullptr);
AlwaysAssert(d_stats.erase(s) > 0)
<< "Statistic `" << s->getName()
<< "' was not registered with this registry.";
#endif /* CVC5_STATISTICS_ON */
} /* StatisticsRegistry::unregisterStat() */
void StatisticsRegistry::flushStat(std::ostream &out) const {
#ifdef CVC5_STATISTICS_ON
flushInformation(out);
#endif /* CVC5_STATISTICS_ON */
}
void StatisticsRegistry::flushInformation(std::ostream &out) const {
#ifdef CVC5_STATISTICS_ON
this->StatisticsBase::flushInformation(out);
#endif /* CVC5_STATISTICS_ON */
}
void StatisticsRegistry::safeFlushInformation(int fd) const {
#ifdef CVC5_STATISTICS_ON
this->StatisticsBase::safeFlushInformation(fd);
#endif /* CVC5_STATISTICS_ON */
}
RegisterStatistic::RegisterStatistic(StatisticsRegistry* reg, Stat* stat)
: d_reg(reg),
d_stat(stat) {
CheckArgument(reg != NULL, reg,
"You need to specify a statistics registry"
"on which to set the statistic");
d_reg->registerStat(d_stat);
}
RegisterStatistic::~RegisterStatistic() {
d_reg->unregisterStat(d_stat);
}
} // namespace cvc5
|