klee
Statistics.cpp
Go to the documentation of this file.
1//===-- Statistics.cpp ----------------------------------------------------===//
2//
3// The KLEE Symbolic Virtual Machine
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
11
12#include <vector>
13
14using namespace klee;
15
16StatisticManager::StatisticManager()
17 : enabled(true),
18 globalStats(0),
19 indexedStats(0),
20 contextStats(0),
21 index(0) {
22}
23
25 delete[] globalStats;
26 delete[] indexedStats;
27}
28
29void StatisticManager::useIndexedStats(unsigned totalIndices) {
30 delete[] indexedStats;
31 indexedStats = new uint64_t[totalIndices * stats.size()];
32 memset(indexedStats, 0, sizeof(*indexedStats) * totalIndices * stats.size());
33}
34
36 delete[] globalStats;
37 s.id = stats.size();
38 stats.push_back(&s);
39 globalStats = new uint64_t[stats.size()];
40 memset(globalStats, 0, sizeof(*globalStats)*stats.size());
41}
42
43int StatisticManager::getStatisticID(const std::string &name) const {
44 for (unsigned i=0; i<stats.size(); i++)
45 if (stats[i]->getName() == name)
46 return i;
47 return -1;
48}
49
50Statistic *StatisticManager::getStatisticByName(const std::string &name) const {
51 for (unsigned i=0; i<stats.size(); i++)
52 if (stats[i]->getName() == name)
53 return stats[i];
54 return 0;
55}
56
58
60 static StatisticManager sm;
62 return sm;
63}
64
65/* *** */
66
67Statistic::Statistic(const std::string &name, const std::string &shortName)
68 : name{name}, shortName{shortName} {
70}
71
72Statistic &Statistic::operator+=(std::uint64_t addend) {
74 return *this;
75}
76
77std::uint64_t Statistic::getValue() const {
78 return theStatisticManager->getValue(*this);
79}
static StatisticManager & getStatisticManager()
Definition: Statistics.cpp:59
std::vector< Statistic * > stats
Definition: Statistics.h:43
int getStatisticID(const std::string &name) const
Definition: Statistics.cpp:43
uint64_t * indexedStats
Definition: Statistics.h:45
uint64_t * globalStats
Definition: Statistics.h:44
void incrementStatistic(Statistic &s, uint64_t addend)
Definition: Statistics.h:76
Statistic * getStatisticByName(const std::string &name) const
Definition: Statistics.cpp:50
void useIndexedStats(unsigned totalIndices)
Definition: Statistics.cpp:29
void registerStatistic(Statistic &s)
Definition: Statistics.cpp:35
uint64_t getValue(const Statistic &s) const
Definition: Statistics.h:132
Statistic & operator+=(std::uint64_t addend)
operator+= - Increment the statistic by
Definition: Statistics.cpp:72
std::uint64_t getValue() const
getValue - Get the current primary statistic value.
Definition: Statistics.cpp:77
Statistic(const std::string &name, const std::string &shortName)
Definition: Statistics.cpp:67
std::uint32_t id
Definition: Statistic.h:31
Definition: main.cpp:291
StatisticManager * theStatisticManager
Definition: Statistics.cpp:57