1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-30 03:32:36 +00:00

Report used memory by Lua interpreter

This commit is contained in:
elsid 2022-09-30 01:46:43 +02:00
parent b1cf4ace3c
commit 4de8ea30c8
No known key found for this signature in database
GPG Key ID: 4DE04C198CBA7625
6 changed files with 16 additions and 17 deletions

View File

@ -442,7 +442,9 @@ bool OMW::Engine::frame(float frametime)
stats->setAttribute(frameNumber, "WorkQueue", mWorkQueue->getNumItems());
stats->setAttribute(frameNumber, "WorkThread", mWorkQueue->getNumActiveThreads());
mEnvironment.reportStats(frameNumber, *stats);
mMechanicsManager->reportStats(frameNumber, *stats);
mWorld->reportStats(frameNumber, *stats);
mLuaManager->reportStats(frameNumber, *stats);
}
}
catch (const std::exception& e)

View File

@ -4,9 +4,6 @@
#include <components/resource/resourcesystem.hpp>
#include "mechanicsmanager.hpp"
#include "world.hpp"
MWBase::Environment* MWBase::Environment::sThis = nullptr;
MWBase::Environment::Environment()
@ -19,9 +16,3 @@ MWBase::Environment::~Environment()
{
sThis = nullptr;
}
void MWBase::Environment::reportStats(unsigned int frameNumber, osg::Stats& stats) const
{
mMechanicsManager->reportStats(frameNumber, stats);
mWorld->reportStats(frameNumber, stats);
}

View File

@ -5,11 +5,6 @@
#include <memory>
namespace osg
{
class Stats;
}
namespace Resource
{
class ResourceSystem;
@ -117,8 +112,6 @@ namespace MWBase
assert(sThis != nullptr);
return *sThis;
}
void reportStats(unsigned int frameNumber, osg::Stats& stats) const;
};
}

View File

@ -2,6 +2,10 @@
#include <filesystem>
#include <osg/Stats>
#include "sol/state_view.hpp"
#include <components/debug/debuglog.hpp>
#include <components/esm/luascripts.hpp>
@ -608,4 +612,9 @@ namespace MWLua
mActionQueue.push_back(std::make_unique<FunctionAction>(&mLua, std::move(action), name));
}
void LuaManager::reportStats(unsigned int frameNumber, osg::Stats& stats)
{
const sol::state_view state(mLua.sol());
stats.setAttribute(frameNumber, "Lua UsedMemory", state.memory_used());
}
}

View File

@ -127,6 +127,8 @@ namespace MWLua
bool isProcessingInputEvents() const { return mProcessingInputEvents; }
void reportStats(unsigned int frameNumber, osg::Stats& stats);
private:
void initConfiguration();
LocalScripts* createLocalScripts(const MWWorld::Ptr& ptr,

View File

@ -463,6 +463,8 @@ namespace Resource
"Physics Objects",
"Physics Projectiles",
"Physics HeightFields",
"",
"Lua UsedMemory",
});
static const auto longest = std::max_element(statNames.begin(), statNames.end(),