1
// Spatial Index Library
3
// Copyright (C) 2002 Navel Ltd.
5
// This library is free software; you can redistribute it and/or
6
// modify it under the terms of the GNU Lesser General Public
7
// License as published by the Free Software Foundation; either
8
// version 2.1 of the License, or (at your option) any later version.
10
// This library is distributed in the hope that it will be useful,
11
// but WITHOUT ANY WARRANTY; without even the implied warranty of
12
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
// Lesser General Public License for more details.
15
// You should have received a copy of the GNU Lesser General Public
16
// License along with this library; if not, write to the Free Software
17
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22
#include "../spatialindex/SpatialIndexImpl.h"
24
#include "Statistics.h"
26
using namespace SpatialIndex::RTree;
28
Statistics::Statistics()
33
Statistics::Statistics(const Statistics& s)
35
m_u64Reads = s.m_u64Reads;
36
m_u64Writes = s.m_u64Writes;
37
m_u64Splits = s.m_u64Splits;
38
m_u64Hits = s.m_u64Hits;
39
m_u64Misses = s.m_u64Misses;
40
m_u32Nodes = s.m_u32Nodes;
41
m_u64Adjustments = s.m_u64Adjustments;
42
m_u64QueryResults = s.m_u64QueryResults;
43
m_u64Data = s.m_u64Data;
44
m_u32TreeHeight = s.m_u32TreeHeight;
45
m_nodesInLevel = s.m_nodesInLevel;
48
Statistics::~Statistics()
52
Statistics& Statistics::operator=(const Statistics& s)
56
m_u64Reads = s.m_u64Reads;
57
m_u64Writes = s.m_u64Writes;
58
m_u64Splits = s.m_u64Splits;
59
m_u64Hits = s.m_u64Hits;
60
m_u64Misses = s.m_u64Misses;
61
m_u32Nodes = s.m_u32Nodes;
62
m_u64Adjustments = s.m_u64Adjustments;
63
m_u64QueryResults = s.m_u64QueryResults;
64
m_u64Data = s.m_u64Data;
65
m_u32TreeHeight = s.m_u32TreeHeight;
66
m_nodesInLevel = s.m_nodesInLevel;
72
uint64_t Statistics::getReads() const
77
uint64_t Statistics::getWrites() const
82
uint32_t Statistics::getNumberOfNodes() const
87
uint64_t Statistics::getNumberOfData() const
92
uint64_t Statistics::getSplits() const
97
uint64_t Statistics::getHits() const
102
uint64_t Statistics::getMisses() const
107
uint64_t Statistics::getAdjustments() const
109
return m_u64Adjustments;
112
uint64_t Statistics::getQueryResults() const
114
return m_u64QueryResults;
117
uint32_t Statistics::getTreeHeight() const
119
return m_u32TreeHeight;
122
uint32_t Statistics::getNumberOfNodesInLevel(uint32_t l) const
127
u32Nodes = m_nodesInLevel.at(l);
131
throw Tools::IndexOutOfBoundsException(l);
137
void Statistics::reset()
145
m_u64Adjustments = 0;
146
m_u64QueryResults = 0;
149
m_nodesInLevel.clear();
152
std::ostream& SpatialIndex::RTree::operator<<(std::ostream& os, const Statistics& s)
154
os << "Reads: " << s.m_u64Reads << std::endl
155
<< "Writes: " << s.m_u64Writes << std::endl
156
<< "Hits: " << s.m_u64Hits << std::endl
157
<< "Misses: " << s.m_u64Misses << std::endl
158
<< "Tree height: " << s.m_u32TreeHeight << std::endl
159
<< "Number of data: " << s.m_u64Data << std::endl
160
<< "Number of nodes: " << s.m_u32Nodes << std::endl;
162
for (uint32_t u32Level = 0; u32Level < s.m_u32TreeHeight; ++u32Level)
164
os << "Level " << u32Level << " pages: " << s.m_nodesInLevel[u32Level] << std::endl;
167
os << "Splits: " << s.m_u64Splits << std::endl
168
<< "Adjustments: " << s.m_u64Adjustments << std::endl
169
<< "Query results: " << s.m_u64QueryResults << std::endl;