diff options
author | Devtools Arcadia <arcadia-devtools@yandex-team.ru> | 2022-02-07 18:08:42 +0300 |
---|---|---|
committer | Devtools Arcadia <arcadia-devtools@mous.vla.yp-c.yandex.net> | 2022-02-07 18:08:42 +0300 |
commit | 1110808a9d39d4b808aef724c861a2e1a38d2a69 (patch) | |
tree | e26c9fed0de5d9873cce7e00bc214573dc2195b7 /contrib/libs/poco/Foundation/src/HashStatistic.cpp | |
download | ydb-1110808a9d39d4b808aef724c861a2e1a38d2a69.tar.gz |
intermediate changes
ref:cde9a383711a11544ce7e107a78147fb96cc4029
Diffstat (limited to 'contrib/libs/poco/Foundation/src/HashStatistic.cpp')
-rw-r--r-- | contrib/libs/poco/Foundation/src/HashStatistic.cpp | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/contrib/libs/poco/Foundation/src/HashStatistic.cpp b/contrib/libs/poco/Foundation/src/HashStatistic.cpp new file mode 100644 index 0000000000..52f618d7aa --- /dev/null +++ b/contrib/libs/poco/Foundation/src/HashStatistic.cpp @@ -0,0 +1,64 @@ +// +// 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( + UInt32 tableSize, + UInt32 numEntries, + UInt32 numZeroEntries, + UInt32 maxEntry, + 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 |