namespace Compressor {
BaseDictionaryCompressor::BaseDictionaryCompressor(const Params *p)
- : Base(p), dictionarySize(p->dictionary_size), numEntries(0)
+ : Base(p), dictionarySize(p->dictionary_size),
+ numEntries(0), dictionaryStats(stats, *this)
+{
+}
+
+BaseDictionaryCompressor::DictionaryStats::DictionaryStats(
+ BaseStats& base_group, BaseDictionaryCompressor& _compressor)
+ : Stats::Group(&base_group), compressor(_compressor),
+ patterns(this, "pattern",
+ "Number of data entries that were compressed to this pattern")
{
}
void
-BaseDictionaryCompressor::regStats()
+BaseDictionaryCompressor::DictionaryStats::regStats()
{
- Base::regStats();
+ Stats::Group::regStats();
// We store the frequency of each pattern
- patternStats
- .init(getNumPatterns())
- .name(name() + ".pattern")
- .desc("Number of data entries that were compressed to this pattern.")
- ;
-
- for (unsigned i = 0; i < getNumPatterns(); ++i) {
- patternStats.subname(i, getName(i));
- patternStats.subdesc(i, "Number of data entries that match pattern " +
- getName(i));
+ patterns.init(compressor.getNumPatterns());
+ for (unsigned i = 0; i < compressor.getNumPatterns(); ++i) {
+ const std::string name = compressor.getName(i);
+ patterns.subname(i, name);
+ patterns.subdesc(i, "Number of data entries that match pattern " +
+ name);
}
}
#include <type_traits>
#include <vector>
+#include "base/statistics.hh"
#include "base/types.hh"
#include "mem/cache/compressors/base.hh"
/** Number of valid entries in the dictionary. */
std::size_t numEntries;
- /**
- * @defgroup CompressionStats Compression specific statistics.
- * @{
- */
+ struct DictionaryStats : public Stats::Group
+ {
+ const BaseDictionaryCompressor& compressor;
- /** Number of data entries that were compressed to each pattern. */
- Stats::Vector patternStats;
+ DictionaryStats(BaseStats &base_group,
+ BaseDictionaryCompressor& _compressor);
- /**
- * @}
- */
+ void regStats() override;
+
+ /** Number of data entries that were compressed to each pattern. */
+ Stats::Vector patterns;
+ } dictionaryStats;
/**
* Trick function to get the number of patterns.
typedef BaseDictionaryCompressorParams Params;
BaseDictionaryCompressor(const Params *p);
~BaseDictionaryCompressor() = default;
-
- void regStats() override;
};
/**