-
Notifications
You must be signed in to change notification settings - Fork 3.5k
/
Copy pathcell_statistics.hpp
54 lines (47 loc) · 1.79 KB
/
cell_statistics.hpp
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
#ifndef OSRM_PARTITIONER_CELL_STATISTICS_HPP
#define OSRM_PARTITIONER_CELL_STATISTICS_HPP
#include "util/log.hpp"
#include "util/typedefs.hpp"
#include <unordered_set>
namespace osrm
{
namespace partitioner
{
template <typename Partition, typename CellStorage>
void printCellStatistics(const Partition &partition, const CellStorage &storage)
{
util::Log() << "Cells statistics per level";
for (std::size_t level = 1; level < partition.GetNumberOfLevels(); ++level)
{
auto num_cells = partition.GetNumberOfCells(level);
std::size_t source = 0, destination = 0;
std::size_t boundary_nodes = 0;
std::size_t entries = 0;
for (std::uint32_t cell_id = 0; cell_id < num_cells; ++cell_id)
{
std::unordered_set<NodeID> boundary;
const auto &cell = storage.GetUnfilledCell(level, cell_id);
source += cell.GetSourceNodes().size();
destination += cell.GetDestinationNodes().size();
for (auto node : cell.GetSourceNodes())
{
boundary.insert(node);
}
for (auto node : cell.GetDestinationNodes())
{
boundary.insert(node);
}
boundary_nodes += boundary.size();
entries += cell.GetSourceNodes().size() * cell.GetDestinationNodes().size();
}
source /= num_cells;
destination /= num_cells;
util::Log() << "Level " << level << " #cells " << num_cells << " #boundary nodes "
<< boundary_nodes << ", sources: avg. " << source << ", destinations: avg. "
<< destination << ", entries: " << entries << " ("
<< (2 * entries * sizeof(EdgeWeight)) << " bytes)";
}
}
} // namespace partitioner
} // namespace osrm
#endif