2021-01-30 07:51:39 +01:00
|
|
|
//
|
|
|
|
// HashStatistic.cpp
|
|
|
|
//
|
|
|
|
// Library: Foundation
|
|
|
|
// Package: Hashing
|
|
|
|
// Module: HashStatistic
|
|
|
|
//
|
|
|
|
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
|
|
|
|
// and Contributors.
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: BSL-1.0
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
#include "Poco/HashStatistic.h"
|
|
|
|
#include <sstream>
|
|
|
|
|
|
|
|
namespace Poco {
|
|
|
|
|
|
|
|
|
|
|
|
HashStatistic::HashStatistic(
|
2023-03-23 19:19:11 +01:00
|
|
|
UInt32 tableSize,
|
|
|
|
UInt32 numEntries,
|
|
|
|
UInt32 numZeroEntries,
|
|
|
|
UInt32 maxEntry,
|
2021-01-30 07:51:39 +01:00
|
|
|
std::vector<UInt32> details):
|
|
|
|
_sizeOfTable(tableSize),
|
|
|
|
_numberOfEntries(numEntries),
|
|
|
|
_numZeroEntries(numZeroEntries),
|
|
|
|
_maxEntriesPerHash(maxEntry),
|
|
|
|
_detailedEntriesPerHash(details)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
HashStatistic::~HashStatistic()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
std::string HashStatistic::toString() const
|
|
|
|
{
|
|
|
|
std::ostringstream str;
|
|
|
|
str << "HashTable of size " << _sizeOfTable << " containing " << _numberOfEntries << " entries:\n";
|
|
|
|
str << " NumberOfZeroEntries: " << _numZeroEntries << "\n";
|
|
|
|
str << " MaxEntry: " << _maxEntriesPerHash << "\n";
|
|
|
|
str << " AvgEntry: " << avgEntriesPerHash() << ", excl Zero slots: " << avgEntriesPerHashExclZeroEntries() << "\n";
|
|
|
|
str << " DetailedStatistics: \n";
|
|
|
|
for (int i = 0; i < _detailedEntriesPerHash.size(); ++i)
|
|
|
|
{
|
|
|
|
// 10 entries per line
|
|
|
|
if (i % 10 == 0)
|
|
|
|
{
|
|
|
|
str << "\n " << i << ":";
|
|
|
|
}
|
|
|
|
str << " " << _detailedEntriesPerHash[i];
|
|
|
|
}
|
|
|
|
str << "\n";
|
|
|
|
str.flush();
|
|
|
|
return str.str();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace Poco
|