mirror of https://github.com/OpenMW/openmw.git
Report more stats from caches
parent
ae41ebfc83
commit
215404e126
@ -0,0 +1,40 @@
|
||||
#include "cachestats.hpp"
|
||||
|
||||
#include <osg/Stats>
|
||||
|
||||
namespace Resource
|
||||
{
|
||||
namespace
|
||||
{
|
||||
std::string makeAttribute(std::string_view prefix, std::string_view suffix)
|
||||
{
|
||||
std::string result;
|
||||
result.reserve(prefix.size() + 1 + suffix.size());
|
||||
result += prefix;
|
||||
result += ' ';
|
||||
result += suffix;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
void addCacheStatsAttibutes(std::string_view prefix, std::vector<std::string>& out)
|
||||
{
|
||||
constexpr std::string_view suffixes[] = {
|
||||
"Count",
|
||||
"Get",
|
||||
"Hit",
|
||||
"Expired",
|
||||
};
|
||||
|
||||
for (std::string_view suffix : suffixes)
|
||||
out.push_back(makeAttribute(prefix, suffix));
|
||||
}
|
||||
|
||||
void reportStats(std::string_view prefix, unsigned frameNumber, const CacheStats& src, osg::Stats& dst)
|
||||
{
|
||||
dst.setAttribute(frameNumber, makeAttribute(prefix, "Count"), static_cast<double>(src.mSize));
|
||||
dst.setAttribute(frameNumber, makeAttribute(prefix, "Get"), static_cast<double>(src.mGet));
|
||||
dst.setAttribute(frameNumber, makeAttribute(prefix, "Hit"), static_cast<double>(src.mHit));
|
||||
dst.setAttribute(frameNumber, makeAttribute(prefix, "Expired"), static_cast<double>(src.mExpired));
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
#ifndef OPENMW_COMPONENTS_RESOURCE_CACHESATS
|
||||
#define OPENMW_COMPONENTS_RESOURCE_CACHESATS
|
||||
|
||||
#include <cstddef>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
namespace osg
|
||||
{
|
||||
class Stats;
|
||||
}
|
||||
|
||||
namespace Resource
|
||||
{
|
||||
struct CacheStats
|
||||
{
|
||||
std::size_t mSize = 0;
|
||||
std::size_t mGet = 0;
|
||||
std::size_t mHit = 0;
|
||||
std::size_t mExpired = 0;
|
||||
};
|
||||
|
||||
void addCacheStatsAttibutes(std::string_view prefix, std::vector<std::string>& out);
|
||||
|
||||
void reportStats(std::string_view prefix, unsigned frameNumber, const CacheStats& src, osg::Stats& dst);
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue