mirror of
https://github.com/holub/mame
synced 2025-04-26 18:23:08 +03:00
Added support for profiling LUA
This commit is contained in:
parent
aa2f9428dc
commit
65e26990d1
@ -159,6 +159,7 @@ void real_profiler_state::update_text(running_machine &machine)
|
|||||||
{ PROFILER_INPUT, "Input Processing" },
|
{ PROFILER_INPUT, "Input Processing" },
|
||||||
{ PROFILER_MOVIE_REC, "Movie Recording" },
|
{ PROFILER_MOVIE_REC, "Movie Recording" },
|
||||||
{ PROFILER_LOGERROR, "Error Logging" },
|
{ PROFILER_LOGERROR, "Error Logging" },
|
||||||
|
{ PROFILER_LUA, "LUA" },
|
||||||
{ PROFILER_EXTRA, "Unaccounted/Overhead" },
|
{ PROFILER_EXTRA, "Unaccounted/Overhead" },
|
||||||
{ PROFILER_USER1, "User 1" },
|
{ PROFILER_USER1, "User 1" },
|
||||||
{ PROFILER_USER2, "User 2" },
|
{ PROFILER_USER2, "User 2" },
|
||||||
|
@ -48,9 +48,10 @@ enum profile_type
|
|||||||
PROFILER_BLIT,
|
PROFILER_BLIT,
|
||||||
PROFILER_SOUND,
|
PROFILER_SOUND,
|
||||||
PROFILER_TIMER_CALLBACK,
|
PROFILER_TIMER_CALLBACK,
|
||||||
PROFILER_INPUT, // input.c and inptport.c
|
PROFILER_INPUT, // input.cpp and inptport.cpp
|
||||||
PROFILER_MOVIE_REC, // movie recording
|
PROFILER_MOVIE_REC, // movie recording
|
||||||
PROFILER_LOGERROR, // logerror
|
PROFILER_LOGERROR, // logerror
|
||||||
|
PROFILER_LUA, // LUA
|
||||||
PROFILER_EXTRA, // everything else
|
PROFILER_EXTRA, // everything else
|
||||||
|
|
||||||
// the USER types are available to driver writers to profile
|
// the USER types are available to driver writers to profile
|
||||||
|
@ -592,7 +592,7 @@ sol::object lua_engine::call_plugin(const std::string &name, sol::object in)
|
|||||||
sol::object obj = sol().registry()[field];
|
sol::object obj = sol().registry()[field];
|
||||||
if(obj.is<sol::protected_function>())
|
if(obj.is<sol::protected_function>())
|
||||||
{
|
{
|
||||||
auto res = (obj.as<sol::protected_function>())(in);
|
auto res = invoke(obj.as<sol::protected_function>(), in);
|
||||||
if(!res.valid())
|
if(!res.valid())
|
||||||
{
|
{
|
||||||
sol::error err = res;
|
sol::error err = res;
|
||||||
@ -610,7 +610,7 @@ void lua_engine::menu_populate(const std::string &menu, std::vector<std::tuple<s
|
|||||||
sol::object obj = sol().registry()[field];
|
sol::object obj = sol().registry()[field];
|
||||||
if(obj.is<sol::protected_function>())
|
if(obj.is<sol::protected_function>())
|
||||||
{
|
{
|
||||||
auto res = (obj.as<sol::protected_function>())();
|
auto res = invoke(obj.as<sol::protected_function>());
|
||||||
if(!res.valid())
|
if(!res.valid())
|
||||||
{
|
{
|
||||||
sol::error err = res;
|
sol::error err = res;
|
||||||
@ -638,7 +638,7 @@ bool lua_engine::menu_callback(const std::string &menu, int index, const std::st
|
|||||||
sol::object obj = sol().registry()[field];
|
sol::object obj = sol().registry()[field];
|
||||||
if(obj.is<sol::protected_function>())
|
if(obj.is<sol::protected_function>())
|
||||||
{
|
{
|
||||||
auto res = (obj.as<sol::protected_function>())(index, event);
|
auto res = invoke(obj.as<sol::protected_function>(), index, event);
|
||||||
if(!res.valid())
|
if(!res.valid())
|
||||||
{
|
{
|
||||||
sol::error err = res;
|
sol::error err = res;
|
||||||
@ -659,7 +659,7 @@ bool lua_engine::execute_function(const char *id)
|
|||||||
{
|
{
|
||||||
if(func.second.is<sol::protected_function>())
|
if(func.second.is<sol::protected_function>())
|
||||||
{
|
{
|
||||||
auto ret = (func.second.as<sol::protected_function>())();
|
auto ret = invoke(func.second.as<sol::protected_function>());
|
||||||
if(!ret.valid())
|
if(!ret.valid())
|
||||||
{
|
{
|
||||||
sol::error err = ret;
|
sol::error err = ret;
|
||||||
@ -2554,7 +2554,7 @@ void lua_engine::run(sol::load_result res)
|
|||||||
{
|
{
|
||||||
if(res.valid())
|
if(res.valid())
|
||||||
{
|
{
|
||||||
auto ret = (res.get<sol::protected_function>())();
|
auto ret = invoke(res.get<sol::protected_function>());
|
||||||
if(!ret.valid())
|
if(!ret.valid())
|
||||||
{
|
{
|
||||||
sol::error err = ret;
|
sol::error err = ret;
|
||||||
@ -2582,3 +2582,16 @@ void lua_engine::load_string(const char *value)
|
|||||||
{
|
{
|
||||||
run(sol().load(value));
|
run(sol().load(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//-------------------------------------------------
|
||||||
|
// invoke - invokes a function, wrapping profiler
|
||||||
|
//-------------------------------------------------
|
||||||
|
|
||||||
|
template<typename TFunc, typename... TArgs>
|
||||||
|
sol::protected_function_result lua_engine::invoke(TFunc &&func, TArgs&&... args)
|
||||||
|
{
|
||||||
|
g_profiler.start(PROFILER_LUA);
|
||||||
|
sol::protected_function_result result = func(std::forward<TArgs>(args)...);
|
||||||
|
g_profiler.stop();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
@ -166,6 +166,9 @@ private:
|
|||||||
bool busy;
|
bool busy;
|
||||||
bool yield;
|
bool yield;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<typename TFunc, typename... TArgs>
|
||||||
|
sol::protected_function_result invoke(TFunc &&func, TArgs&&... args);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MAME_FRONTEND_MAME_LUAENGINE_H
|
#endif // MAME_FRONTEND_MAME_LUAENGINE_H
|
||||||
|
Loading…
Reference in New Issue
Block a user