klee
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 
10 #include "klee/Statistics.h"
11 
12 #include <vector>
13 
14 using namespace klee;
15 
17  : enabled(true),
18  globalStats(0),
19  indexedStats(0),
20  contextStats(0),
21  index(0) {
22 }
23 
25  if (globalStats) delete[] globalStats;
26  if (indexedStats) delete[] indexedStats;
27 }
28 
29 void StatisticManager::useIndexedStats(unsigned totalIndices) {
30  if (indexedStats) delete[] indexedStats;
31  indexedStats = new uint64_t[totalIndices * stats.size()];
32  memset(indexedStats, 0, sizeof(*indexedStats) * totalIndices * stats.size());
33 }
34 
36  if (globalStats) 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 
43 int 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 
50 Statistic *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;
61  theStatisticManager = &sm;
62  return sm;
63 }
64 
65 /* *** */
66 
67 Statistic::Statistic(const std::string &_name,
68  const std::string &_shortName)
69  : name(_name),
70  shortName(_shortName) {
72 }
73 
75 }
76 
77 Statistic &Statistic::operator +=(const uint64_t addend) {
79  return *this;
80 }
81 
82 uint64_t Statistic::getValue() const {
83  return theStatisticManager->getValue(*this);
84 }
std::vector< Statistic * > stats
Definition: Statistics.h:43
StatisticManager * theStatisticManager
Definition: Statistics.cpp:57
Statistic(const std::string &_name, const std::string &_shortName)
Definition: Statistics.cpp:67
static StatisticManager & getStatisticManager()
Definition: Statistics.cpp:59
Statistic & operator+=(const uint64_t addend)
operator+= - Increment the statistic by
Definition: Statistics.cpp:77
uint64_t getValue() const
getValue - Get the current primary statistic value.
Definition: Statistics.cpp:82
void registerStatistic(Statistic &s)
Definition: Statistics.cpp:35
unsigned id
Definition: Statistic.h:33
Statistic * getStatisticByName(const std::string &name) const
Definition: Statistics.cpp:50
uint64_t getValue(const Statistic &s) const
Definition: Statistics.h:132
void useIndexedStats(unsigned totalIndices)
Definition: Statistics.cpp:29
void incrementStatistic(Statistic &s, uint64_t addend)
Definition: Statistics.h:76
uint64_t * globalStats
Definition: Statistics.h:44
uint64_t * indexedStats
Definition: Statistics.h:45
int getStatisticID(const std::string &name) const
Definition: Statistics.cpp:43