Skip to content

Commit

Permalink
Respect -nojit option on startup with profiling active. Corrected sto…
Browse files Browse the repository at this point in the history
…p method.
  • Loading branch information
Neloreck committed Jan 17, 2025
1 parent d3d5aa3 commit 78232f2
Showing 1 changed file with 12 additions and 18 deletions.
30 changes: 12 additions & 18 deletions src/xrScriptEngine/script_profiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@ void CScriptProfiler::startSamplingMode(u32 sampling_interval)
return;
}

if (!luaIsJitProfilerDefined(lua()))
{
Msg("[P] Cannot start scripts sampling profiler, jit module is not defined");
return;
}

if (!lua())
{
Msg("[P] Activating sampling profiler on lua engine start, waiting init");
Expand All @@ -94,12 +100,6 @@ void CScriptProfiler::startSamplingMode(u32 sampling_interval)
return;
}

if (!luaIsJitProfilerDefined(lua()))
{
Msg("[P] Cannot start scripts sampling profiler, jit module is not defined");
return;
}

clamp(sampling_interval, 1u, PROFILE_SAMPLING_INTERVAL_MAX);

Msg("[P] Starting scripts sampling profiler, interval: %d", sampling_interval);
Expand All @@ -119,33 +119,27 @@ void CScriptProfiler::stop()
return;
}

if (m_profiler_type == CScriptProfilerType::None)
{
Msg("[P] Tried to stop none type profiler");
return;
}

switch (m_profiler_type)
{
case CScriptProfilerType::Hook:
Msg("[P] Stopping scripts hook profiler");

// Do not detach hook here, adding it means that it is already test run in the first place.

break;
case CScriptProfilerType::Sampling:
{
Msg("[P] Stopping scripts sampling profiler");

// Detach profiler from luajit, stop operation will be ignore anyway if it is stopped/captured by another VM.
luaJitProfilerStop(lua());

break;
}

default: NODEFAULT;
default:
Msg("[P] Tried to stop none type profiler");
return;
}

m_active = false;
m_hook_profiling_portions.clear();
m_sampling_profiling_log.clear();
}

void CScriptProfiler::reset()
Expand Down

0 comments on commit 78232f2

Please sign in to comment.