mirror of https://github.com/OpenMW/openmw.git
Separate reading navigator stats and reporting
parent
e9be8b5efe
commit
c15848932b
@ -0,0 +1,40 @@
|
||||
#include "stats.hpp"
|
||||
|
||||
#include <osg/Stats>
|
||||
|
||||
namespace DetourNavigator
|
||||
{
|
||||
namespace
|
||||
{
|
||||
void reportStats(const AsyncNavMeshUpdaterStats& stats, unsigned int frameNumber, osg::Stats& out)
|
||||
{
|
||||
out.setAttribute(frameNumber, "NavMesh Jobs", static_cast<double>(stats.mJobs));
|
||||
out.setAttribute(frameNumber, "NavMesh Waiting", static_cast<double>(stats.mWaiting));
|
||||
out.setAttribute(frameNumber, "NavMesh Pushed", static_cast<double>(stats.mPushed));
|
||||
out.setAttribute(frameNumber, "NavMesh Processing", static_cast<double>(stats.mProcessing));
|
||||
|
||||
if (stats.mDb.has_value())
|
||||
{
|
||||
out.setAttribute(frameNumber, "NavMesh DbJobs Write", static_cast<double>(stats.mDb->mJobs.mWritingJobs));
|
||||
out.setAttribute(frameNumber, "NavMesh DbJobs Read", static_cast<double>(stats.mDb->mJobs.mReadingJobs));
|
||||
|
||||
if (stats.mDb->mGetTileCount > 0)
|
||||
out.setAttribute(frameNumber, "NavMesh DbCacheHitRate", static_cast<double>(stats.mDbGetTileHits)
|
||||
/ static_cast<double>(stats.mDb->mGetTileCount) * 100.0);
|
||||
}
|
||||
|
||||
out.setAttribute(frameNumber, "NavMesh CacheSize", static_cast<double>(stats.mCache.mNavMeshCacheSize));
|
||||
out.setAttribute(frameNumber, "NavMesh UsedTiles", static_cast<double>(stats.mCache.mUsedNavMeshTiles));
|
||||
out.setAttribute(frameNumber, "NavMesh CachedTiles", static_cast<double>(stats.mCache.mCachedNavMeshTiles));
|
||||
if (stats.mCache.mGetCount > 0)
|
||||
out.setAttribute(frameNumber, "NavMesh CacheHitRate", static_cast<double>(stats.mCache.mHitCount)
|
||||
/ stats.mCache.mGetCount * 100.0);
|
||||
}
|
||||
}
|
||||
|
||||
void reportStats(const Stats& stats, unsigned int frameNumber, osg::Stats& out)
|
||||
{
|
||||
if (stats.mUpdater.has_value())
|
||||
reportStats(*stats.mUpdater, frameNumber, out);
|
||||
}
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
#ifndef OPENMW_COMPONENTS_DETOURNAVIGATOR_STATS_H
|
||||
#define OPENMW_COMPONENTS_DETOURNAVIGATOR_STATS_H
|
||||
|
||||
#include <cstddef>
|
||||
#include <optional>
|
||||
|
||||
namespace osg
|
||||
{
|
||||
class Stats;
|
||||
}
|
||||
|
||||
namespace DetourNavigator
|
||||
{
|
||||
struct DbJobQueueStats
|
||||
{
|
||||
std::size_t mWritingJobs = 0;
|
||||
std::size_t mReadingJobs = 0;
|
||||
};
|
||||
|
||||
struct DbWorkerStats
|
||||
{
|
||||
DbJobQueueStats mJobs;
|
||||
std::size_t mGetTileCount = 0;
|
||||
};
|
||||
|
||||
struct NavMeshTilesCacheStats
|
||||
{
|
||||
std::size_t mNavMeshCacheSize = 0;
|
||||
std::size_t mUsedNavMeshTiles = 0;
|
||||
std::size_t mCachedNavMeshTiles = 0;
|
||||
std::size_t mHitCount = 0;
|
||||
std::size_t mGetCount = 0;
|
||||
};
|
||||
|
||||
struct AsyncNavMeshUpdaterStats
|
||||
{
|
||||
std::size_t mJobs = 0;
|
||||
std::size_t mWaiting = 0;
|
||||
std::size_t mPushed = 0;
|
||||
std::size_t mProcessing = 0;
|
||||
std::size_t mDbGetTileHits = 0;
|
||||
std::optional<DbWorkerStats> mDb;
|
||||
NavMeshTilesCacheStats mCache;
|
||||
};
|
||||
|
||||
struct Stats
|
||||
{
|
||||
std::optional<AsyncNavMeshUpdaterStats> mUpdater;
|
||||
};
|
||||
|
||||
void reportStats(const Stats& stats, unsigned int frameNumber, osg::Stats& out);
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue