1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-31 20:45:34 +00:00

Merge branch 'lua_stats_used_memory_48' into 'openmw-48'

Report used memory by Lua interpreter (0.48)

See merge request OpenMW/openmw!2445
This commit is contained in:
psi29a 2022-09-30 11:42:02 +00:00
commit 37ee7170cb
6 changed files with 16 additions and 25 deletions

View file

@ -440,7 +440,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,17 +4,6 @@
#include <components/resource/resourcesystem.hpp>
#include "world.hpp"
#include "scriptmanager.hpp"
#include "dialoguemanager.hpp"
#include "journal.hpp"
#include "soundmanager.hpp"
#include "mechanicsmanager.hpp"
#include "inputmanager.hpp"
#include "windowmanager.hpp"
#include "statemanager.hpp"
#include "luamanager.hpp"
MWBase::Environment *MWBase::Environment::sThis = nullptr;
MWBase::Environment::Environment()
@ -27,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;
@ -118,8 +113,6 @@ namespace MWBase
assert(sThis != nullptr);
return *sThis;
}
void reportStats(unsigned int frameNumber, osg::Stats& stats) const;
};
}

View file

@ -1,5 +1,9 @@
#include "luamanagerimp.hpp"
#include <osg/Stats>
#include "sol/state_view.hpp"
#include <components/debug/debuglog.hpp>
#include <components/esm3/esmreader.hpp>
@ -598,4 +602,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

@ -126,6 +126,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

@ -453,6 +453,8 @@ void StatsHandler::setUpScene(osgViewer::ViewerBase *viewer)
"Physics Objects",
"Physics Projectiles",
"Physics HeightFields",
"",
"Lua UsedMemory",
});
static const auto longest = std::max_element(statNames.begin(), statNames.end(),