libspatialindex API Reference  (git-trunk)
tprtree/Statistics.cc
Go to the documentation of this file.
1 /******************************************************************************
2  * Project: libspatialindex - A C++ library for spatial indexing
3  * Author: Marios Hadjieleftheriou, mhadji@gmail.com
4  ******************************************************************************
5  * Copyright (c) 2002, Marios Hadjieleftheriou
6  *
7  * All rights reserved.
8  *
9  * Permission is hereby granted, free of charge, to any person obtaining a
10  * copy of this software and associated documentation files (the "Software"),
11  * to deal in the Software without restriction, including without limitation
12  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13  * and/or sell copies of the Software, and to permit persons to whom the
14  * Software is furnished to do so, subject to the following conditions:
15  *
16  * The above copyright notice and this permission notice shall be included
17  * in all copies or substantial portions of the Software.
18  *
19  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25  * DEALINGS IN THE SOFTWARE.
26 ******************************************************************************/
27 
29 
30 #include "Statistics.h"
31 
32 using namespace SpatialIndex::TPRTree;
33 
35 {
36  reset();
37 }
38 
40 {
41  m_reads = s.m_reads;
42  m_writes = s.m_writes;
43  m_splits = s.m_splits;
44  m_hits = s.m_hits;
45  m_misses = s.m_misses;
46  m_nodes = s.m_nodes;
47  m_adjustments = s.m_adjustments;
48  m_queryResults = s.m_queryResults;
49  m_data = s.m_data;
50  m_treeHeight = s.m_treeHeight;
51  m_nodesInLevel = s.m_nodesInLevel;
52 }
53 
55 = default;
56 
58 {
59  if (this != &s)
60  {
61  m_reads = s.m_reads;
62  m_writes = s.m_writes;
63  m_splits = s.m_splits;
64  m_hits = s.m_hits;
65  m_misses = s.m_misses;
66  m_nodes = s.m_nodes;
67  m_adjustments = s.m_adjustments;
68  m_queryResults = s.m_queryResults;
69  m_data = s.m_data;
70  m_treeHeight = s.m_treeHeight;
71  m_nodesInLevel = s.m_nodesInLevel;
72  }
73 
74  return *this;
75 }
76 
77 uint64_t Statistics::getReads() const
78 {
79  return m_reads;
80 }
81 
82 uint64_t Statistics::getWrites() const
83 {
84  return m_writes;
85 }
86 
88 {
89  return m_nodes;
90 }
91 
93 {
94  return m_data;
95 }
96 
97 uint64_t Statistics::getSplits() const
98 {
99  return m_splits;
100 }
101 
102 uint64_t Statistics::getHits() const
103 {
104  return m_hits;
105 }
106 
107 uint64_t Statistics::getMisses() const
108 {
109  return m_misses;
110 }
111 
113 {
114  return m_adjustments;
115 }
116 
118 {
119  return m_queryResults;
120 }
121 
123 {
124  return m_treeHeight;
125 }
126 
127 uint32_t Statistics::getNumberOfNodesInLevel(uint32_t l) const
128 {
129  uint32_t cNodes;
130  try
131  {
132  cNodes = m_nodesInLevel.at(l);
133  }
134  catch (...)
135  {
137  }
138 
139  return cNodes;
140 }
141 
142 void Statistics::reset()
143 {
144  m_reads = 0;
145  m_writes = 0;
146  m_splits = 0;
147  m_hits = 0;
148  m_misses = 0;
149  m_nodes = 0;
150  m_adjustments = 0;
151  m_queryResults = 0;
152  m_data = 0;
153  m_treeHeight = 0;
154  m_nodesInLevel.clear();
155 }
156 
157 std::ostream& SpatialIndex::TPRTree::operator<<(std::ostream& os, const Statistics& s)
158 {
159  os << "Reads: " << s.m_reads << std::endl
160  << "Writes: " << s.m_writes << std::endl
161  << "Hits: " << s.m_hits << std::endl
162  << "Misses: " << s.m_misses << std::endl
163  << "Tree height: " << s.m_treeHeight << std::endl
164  << "Number of data: " << s.m_data << std::endl
165  << "Number of nodes: " << s.m_nodes << std::endl;
166 
167  for (uint32_t cLevel = 0; cLevel < s.m_treeHeight; ++cLevel)
168  {
169  os << "Level " << cLevel << " pages: " << s.m_nodesInLevel[cLevel] << std::endl;
170  }
171 
172  os << "Splits: " << s.m_splits << std::endl
173  << "Adjustments: " << s.m_adjustments << std::endl
174  << "Query results: " << s.m_queryResults << std::endl;
175 
176  return os;
177 }
uint64_t getNumberOfData() const override
uint32_t getNumberOfNodes() const override
std::ostream & operator<<(std::ostream &os, const Statistics &s)
virtual uint64_t getMisses() const
Statistics & operator=(const Statistics &)
virtual uint64_t getQueryResults() const
virtual uint64_t getSplits() const
virtual uint32_t getTreeHeight() const
virtual uint64_t getAdjustments() const
uint64_t getWrites() const override
uint64_t getReads() const override
virtual uint32_t getNumberOfNodesInLevel(uint32_t l) const