1
0
forked from 0ad/0ad

Some tweaks to profiler2:

* separate the HTTP profiling server from the on-screen profiler
* allow shutting down the HTTP profiler
* print messages when enabling/disabling HTTP and GPU profilers

Patch by kingbasil, fixes #1862

This was SVN commit r15723.
This commit is contained in:
Nicolas Auvray 2014-09-09 18:17:08 +00:00
parent bdd8bc1f44
commit 7ada7dd2a8
5 changed files with 48 additions and 10 deletions

View File

@ -328,11 +328,10 @@ hotkey.text.move.right = "Ctrl+RightArrow" ; Move cursor to start of word to
; > PROFILER
hotkey.profile.toggle = "F11" ; Enable/disable real-time profiler
hotkey.profile.save = "Shift+F11" ; Save current profiler data to logs/profile.txt
hotkey.profile2.enable = "F11" ; Enable HTTP/GPU modes for new profiler
hotkey.profile2.toggle = "Ctrl+F11" ; Enable/disable HTTP/GPU modes for new profiler
profiler2.http.autoenable = false ; Enable HTTP server output at startup (default off for security/performance)
profiler2.autoenable = false ; Enable HTTP server output at startup (default off for security/performance)
profiler2.script.enable = false ; Enable Javascript profiling. Needs to be set before startup and can't be changed later. (default off for performance)
profiler2.gpu.autoenable = false ; Enable GPU timing at startup (default off for performance/compatibility)
profiler2.gpu.arb.enable = true ; Allow GL_ARB_timer_query timing mode when available
profiler2.gpu.ext.enable = true ; Allow GL_EXT_timer_query timing mode when available
profiler2.gpu.intel.enable = true ; Allow GL_INTEL_performance_queries timing mode when available

View File

@ -161,10 +161,9 @@ static InReaction MainInputHandler(const SDL_Event_* ev)
#endif
return IN_HANDLED;
}
else if (hotkey == "profile2.enable")
else if (hotkey == "profile2.toggle")
{
g_Profiler2.EnableGPU();
g_Profiler2.EnableHTTP();
g_Profiler2.Toggle();
return IN_HANDLED;
}
break;

View File

@ -955,7 +955,7 @@ bool Init(const CmdLineArgs& args, int flags)
// Optionally start profiler HTTP output automatically
// (By default it's only enabled by a hotkey, for security/performance)
bool profilerHTTPEnable = false;
CFG_GET_VAL("profiler2.http.autoenable", Bool, profilerHTTPEnable);
CFG_GET_VAL("profiler2.autoenable", Bool, profilerHTTPEnable);
if (profilerHTTPEnable)
g_Profiler2.EnableHTTP();
@ -992,7 +992,7 @@ void InitGraphics(const CmdLineArgs& args, int flags)
// Optionally start profiler GPU timings automatically
// (By default it's only enabled by a hotkey, for performance/compatibility)
bool profilerGPUEnable = false;
CFG_GET_VAL("profiler2.gpu.autoenable", Bool, profilerGPUEnable);
CFG_GET_VAL("profiler2.autoenable", Bool, profilerGPUEnable);
if (profilerGPUEnable)
g_Profiler2.EnableGPU();

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2011 Wildfire Games
/* Copyright (c) 2014 Wildfire Games
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
@ -157,6 +157,7 @@ void CProfiler2::InitialiseGPU()
void CProfiler2::EnableHTTP()
{
ENSURE(m_Initialised);
LOGMESSAGERENDER(L"Starting profiler2 HTTP server");
// Ignore multiple enablings
if (m_MgContext)
@ -175,14 +176,43 @@ void CProfiler2::EnableGPU()
{
ENSURE(m_Initialised);
if (!m_GPU)
{
LOGMESSAGERENDER(L"Starting profiler2 GPU mode");
InitialiseGPU();
}
}
void CProfiler2::ShutdownGPU()
{
LOGMESSAGERENDER(L"Shutting down profiler2 GPU mode");
SAFE_DELETE(m_GPU);
}
void CProfiler2::ShutDownHTTP()
{
LOGMESSAGERENDER(L"Shutting down profiler2 HTTP server");
if (m_MgContext)
{
mg_stop(m_MgContext);
m_MgContext = NULL;
}
}
void CProfiler2::Toggle()
{
// TODO: Maybe we can open the browser to the profiler page automatically
if (m_GPU && m_MgContext)
{
ShutdownGPU();
ShutDownHTTP();
}
else if (!m_GPU && !m_MgContext)
{
EnableGPU();
EnableHTTP();
}
}
void CProfiler2::Shutdown()
{
ENSURE(m_Initialised);

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2011 Wildfire Games
/* Copyright (c) 2014 Wildfire Games
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
@ -275,6 +275,16 @@ public:
*/
void ShutdownGPU();
/**
* Call in main thread to shut down the profiler's HTTP server
*/
void ShutDownHTTP();
/**
* Call in main thread to enable/disable the profiler
*/
void Toggle();
/**
* Call in main thread to shut everything down.
* All other profiled threads should have been terminated already.