Separate some profiling code from main_loop.cpp, see #43
This commit is contained in:
parent
b9334e3722
commit
825ebb3335
3 changed files with 197 additions and 117 deletions
|
@ -150,7 +150,9 @@
|
||||||
#include "nel/gui/lua_manager.h"
|
#include "nel/gui/lua_manager.h"
|
||||||
#include "nel/gui/group_table.h"
|
#include "nel/gui/group_table.h"
|
||||||
|
|
||||||
|
// pulled from main_loop.cpp
|
||||||
#include "ping.h"
|
#include "ping.h"
|
||||||
|
#include "profiling.h"
|
||||||
|
|
||||||
|
|
||||||
///////////
|
///////////
|
||||||
|
@ -253,12 +255,6 @@ uint8 ShowInfos = 0; // 0=no info 1=text info 2=graph info
|
||||||
|
|
||||||
bool bZeroCpu = false; // For no Cpu use if application is minimize TODO: intercept minimize message, called by CTRL + Z at this
|
bool bZeroCpu = false; // For no Cpu use if application is minimize TODO: intercept minimize message, called by CTRL + Z at this
|
||||||
|
|
||||||
bool Profiling = false; // Are we in Profile mode?
|
|
||||||
uint ProfileNumFrame = 0;
|
|
||||||
bool WantProfiling = false;
|
|
||||||
bool ProfilingVBLock = false;
|
|
||||||
bool WantProfilingVBLock = false;
|
|
||||||
|
|
||||||
bool MovieShooterSaving= false; // Are we in Shooting mode?
|
bool MovieShooterSaving= false; // Are we in Shooting mode?
|
||||||
|
|
||||||
|
|
||||||
|
@ -415,119 +411,8 @@ void buildCameraClippingPyramid (vector<CPlane> &planes)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//---------------------------------------------------
|
|
||||||
// Test Profiling and run?
|
|
||||||
//---------------------------------------------------
|
|
||||||
void testLaunchProfile()
|
|
||||||
{
|
|
||||||
if(!WantProfiling)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// comes from ActionHandler
|
|
||||||
WantProfiling= false;
|
|
||||||
|
|
||||||
#ifdef _PROFILE_ON_
|
|
||||||
if( !Profiling )
|
|
||||||
{
|
|
||||||
// start the bench.
|
|
||||||
NLMISC::CHTimer::startBench();
|
|
||||||
ProfileNumFrame = 0;
|
|
||||||
Driver->startBench();
|
|
||||||
if (SoundMngr)
|
|
||||||
SoundMngr->getMixer()->startDriverBench();
|
|
||||||
// state
|
|
||||||
Profiling= true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// end the bench.
|
|
||||||
if (SoundMngr)
|
|
||||||
SoundMngr->getMixer()->endDriverBench();
|
|
||||||
NLMISC::CHTimer::endBench();
|
|
||||||
Driver->endBench();
|
|
||||||
|
|
||||||
|
|
||||||
// Display and save profile to a File.
|
|
||||||
CLog log;
|
|
||||||
CFileDisplayer fileDisplayer(NLMISC::CFile::findNewFile(getLogDirectory() + "profile.log"));
|
|
||||||
CStdDisplayer stdDisplayer;
|
|
||||||
log.addDisplayer(&fileDisplayer);
|
|
||||||
log.addDisplayer(&stdDisplayer);
|
|
||||||
// diplay
|
|
||||||
NLMISC::CHTimer::displayHierarchicalByExecutionPathSorted(&log, CHTimer::TotalTime, true, 48, 2);
|
|
||||||
NLMISC::CHTimer::displayHierarchical(&log, true, 48, 2);
|
|
||||||
NLMISC::CHTimer::displayByExecutionPath(&log, CHTimer::TotalTime);
|
|
||||||
NLMISC::CHTimer::display(&log, CHTimer::TotalTime);
|
|
||||||
NLMISC::CHTimer::display(&log, CHTimer::TotalTimeWithoutSons);
|
|
||||||
Driver->displayBench(&log);
|
|
||||||
|
|
||||||
if (SoundMngr)
|
|
||||||
SoundMngr->getMixer()->displayDriverBench(&log);
|
|
||||||
|
|
||||||
// state
|
|
||||||
Profiling= false;
|
|
||||||
}
|
|
||||||
#endif // #ifdef _PROFILE_ON_
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//---------------------------------------------------
|
|
||||||
// Test ProfilingVBLock and run?
|
|
||||||
//---------------------------------------------------
|
|
||||||
void testLaunchProfileVBLock()
|
|
||||||
{
|
|
||||||
// If running, must stop for this frame.
|
|
||||||
if(ProfilingVBLock)
|
|
||||||
{
|
|
||||||
vector<string> strs;
|
|
||||||
Driver->endProfileVBHardLock(strs);
|
|
||||||
nlinfo("Profile VBLock");
|
|
||||||
nlinfo("**************");
|
|
||||||
for(uint i=0;i<strs.size();i++)
|
|
||||||
{
|
|
||||||
nlinfo(strs[i].c_str());
|
|
||||||
}
|
|
||||||
ProfilingVBLock= false;
|
|
||||||
|
|
||||||
// Display additional info on allocated VBHards
|
|
||||||
nlinfo("VBHard list");
|
|
||||||
nlinfo("**************");
|
|
||||||
Driver->profileVBHardAllocation(strs);
|
|
||||||
for(uint i=0;i<strs.size();i++)
|
|
||||||
{
|
|
||||||
nlinfo(strs[i].c_str());
|
|
||||||
}
|
|
||||||
strs.clear();
|
|
||||||
Driver->endProfileIBLock(strs);
|
|
||||||
nlinfo("Profile Index Buffer Lock");
|
|
||||||
nlinfo("**************");
|
|
||||||
for(uint i=0;i<strs.size();i++)
|
|
||||||
{
|
|
||||||
nlinfo(strs[i].c_str());
|
|
||||||
}
|
|
||||||
ProfilingVBLock= false;
|
|
||||||
|
|
||||||
// Display additional info on allocated VBHards
|
|
||||||
/*
|
|
||||||
nlinfo("Index Buffer list");
|
|
||||||
nlinfo("**************");
|
|
||||||
Driver->profileIBAllocation(strs);
|
|
||||||
for(uint i=0;i<strs.size();i++)
|
|
||||||
{
|
|
||||||
nlinfo(strs[i].c_str());
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
// comes from ActionHandler
|
|
||||||
if(WantProfilingVBLock)
|
|
||||||
{
|
|
||||||
WantProfilingVBLock= false;
|
|
||||||
ProfilingVBLock= true;
|
|
||||||
Driver->startProfileVBHardLock();
|
|
||||||
Driver->startProfileIBLock();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//---------------------------------------------------
|
//---------------------------------------------------
|
||||||
|
|
159
code/ryzom/client/src/profiling.cpp
Normal file
159
code/ryzom/client/src/profiling.cpp
Normal file
|
@ -0,0 +1,159 @@
|
||||||
|
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
||||||
|
// Copyright (C) 2010 Winch Gate Property Limited
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as
|
||||||
|
// published by the Free Software Foundation, either version 3 of the
|
||||||
|
// License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
#include "profiling.h"
|
||||||
|
|
||||||
|
// NeL includes
|
||||||
|
#include <nel/3d/u_driver.h>
|
||||||
|
|
||||||
|
// Project includes
|
||||||
|
#include "misc.h"
|
||||||
|
#include "sound_manager.h"
|
||||||
|
|
||||||
|
///////////
|
||||||
|
// USING //
|
||||||
|
///////////
|
||||||
|
using namespace NLMISC;
|
||||||
|
using namespace NL3D;
|
||||||
|
|
||||||
|
////////////
|
||||||
|
// EXTERN //
|
||||||
|
////////////
|
||||||
|
extern UDriver *Driver;
|
||||||
|
|
||||||
|
/////////////
|
||||||
|
// GLOBALS //
|
||||||
|
/////////////
|
||||||
|
bool Profiling = false; // Are we in Profile mode?
|
||||||
|
uint ProfileNumFrame = 0;
|
||||||
|
bool WantProfiling = false;
|
||||||
|
bool ProfilingVBLock = false;
|
||||||
|
bool WantProfilingVBLock = false;
|
||||||
|
|
||||||
|
// ********************************************************************
|
||||||
|
|
||||||
|
/// Test Profiling and run?
|
||||||
|
void testLaunchProfile()
|
||||||
|
{
|
||||||
|
if(!WantProfiling)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// comes from ActionHandler
|
||||||
|
WantProfiling= false;
|
||||||
|
|
||||||
|
#ifdef _PROFILE_ON_
|
||||||
|
if( !Profiling )
|
||||||
|
{
|
||||||
|
// start the bench.
|
||||||
|
NLMISC::CHTimer::startBench();
|
||||||
|
ProfileNumFrame = 0;
|
||||||
|
Driver->startBench();
|
||||||
|
if (SoundMngr)
|
||||||
|
SoundMngr->getMixer()->startDriverBench();
|
||||||
|
// state
|
||||||
|
Profiling= true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// end the bench.
|
||||||
|
if (SoundMngr)
|
||||||
|
SoundMngr->getMixer()->endDriverBench();
|
||||||
|
NLMISC::CHTimer::endBench();
|
||||||
|
Driver->endBench();
|
||||||
|
|
||||||
|
|
||||||
|
// Display and save profile to a File.
|
||||||
|
CLog log;
|
||||||
|
CFileDisplayer fileDisplayer(NLMISC::CFile::findNewFile(getLogDirectory() + "profile.log"));
|
||||||
|
CStdDisplayer stdDisplayer;
|
||||||
|
log.addDisplayer(&fileDisplayer);
|
||||||
|
log.addDisplayer(&stdDisplayer);
|
||||||
|
// diplay
|
||||||
|
NLMISC::CHTimer::displayHierarchicalByExecutionPathSorted(&log, CHTimer::TotalTime, true, 48, 2);
|
||||||
|
NLMISC::CHTimer::displayHierarchical(&log, true, 48, 2);
|
||||||
|
NLMISC::CHTimer::displayByExecutionPath(&log, CHTimer::TotalTime);
|
||||||
|
NLMISC::CHTimer::display(&log, CHTimer::TotalTime);
|
||||||
|
NLMISC::CHTimer::display(&log, CHTimer::TotalTimeWithoutSons);
|
||||||
|
Driver->displayBench(&log);
|
||||||
|
|
||||||
|
if (SoundMngr)
|
||||||
|
SoundMngr->getMixer()->displayDriverBench(&log);
|
||||||
|
|
||||||
|
// state
|
||||||
|
Profiling= false;
|
||||||
|
}
|
||||||
|
#endif // #ifdef _PROFILE_ON_
|
||||||
|
}
|
||||||
|
|
||||||
|
// ********************************************************************
|
||||||
|
|
||||||
|
/// Test ProfilingVBLock and run?
|
||||||
|
void testLaunchProfileVBLock()
|
||||||
|
{
|
||||||
|
// If running, must stop for this frame.
|
||||||
|
if(ProfilingVBLock)
|
||||||
|
{
|
||||||
|
std::vector<string> strs;
|
||||||
|
Driver->endProfileVBHardLock(strs);
|
||||||
|
nlinfo("Profile VBLock");
|
||||||
|
nlinfo("**************");
|
||||||
|
for(uint i=0;i<strs.size();i++)
|
||||||
|
{
|
||||||
|
nlinfo(strs[i].c_str());
|
||||||
|
}
|
||||||
|
ProfilingVBLock= false;
|
||||||
|
|
||||||
|
// Display additional info on allocated VBHards
|
||||||
|
nlinfo("VBHard list");
|
||||||
|
nlinfo("**************");
|
||||||
|
Driver->profileVBHardAllocation(strs);
|
||||||
|
for(uint i=0;i<strs.size();i++)
|
||||||
|
{
|
||||||
|
nlinfo(strs[i].c_str());
|
||||||
|
}
|
||||||
|
strs.clear();
|
||||||
|
Driver->endProfileIBLock(strs);
|
||||||
|
nlinfo("Profile Index Buffer Lock");
|
||||||
|
nlinfo("**************");
|
||||||
|
for(uint i=0;i<strs.size();i++)
|
||||||
|
{
|
||||||
|
nlinfo(strs[i].c_str());
|
||||||
|
}
|
||||||
|
ProfilingVBLock= false;
|
||||||
|
|
||||||
|
// Display additional info on allocated VBHards
|
||||||
|
/*
|
||||||
|
nlinfo("Index Buffer list");
|
||||||
|
nlinfo("**************");
|
||||||
|
Driver->profileIBAllocation(strs);
|
||||||
|
for(uint i=0;i<strs.size();i++)
|
||||||
|
{
|
||||||
|
nlinfo(strs[i].c_str());
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
// comes from ActionHandler
|
||||||
|
if(WantProfilingVBLock)
|
||||||
|
{
|
||||||
|
WantProfilingVBLock= false;
|
||||||
|
ProfilingVBLock= true;
|
||||||
|
Driver->startProfileVBHardLock();
|
||||||
|
Driver->startProfileIBLock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* end of file */
|
36
code/ryzom/client/src/profiling.h
Normal file
36
code/ryzom/client/src/profiling.h
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
||||||
|
// Copyright (C) 2010 Winch Gate Property Limited
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as
|
||||||
|
// published by the Free Software Foundation, either version 3 of the
|
||||||
|
// License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
#ifndef CL_MAIN_LOOP_PROFILING_H
|
||||||
|
#define CL_MAIN_LOOP_PROFILING_H
|
||||||
|
|
||||||
|
#include <nel/misc/types_nl.h>
|
||||||
|
|
||||||
|
extern bool Profiling; // Are we in Profile mode?
|
||||||
|
extern uint ProfileNumFrame;
|
||||||
|
extern bool WantProfiling;
|
||||||
|
extern bool ProfilingVBLock;
|
||||||
|
extern bool WantProfilingVBLock;
|
||||||
|
|
||||||
|
/// Test Profiling and run?
|
||||||
|
void testLaunchProfile();
|
||||||
|
|
||||||
|
/// Test ProfilingVBLock and run?
|
||||||
|
void testLaunchProfileVBLock();
|
||||||
|
|
||||||
|
#endif // CL_MAIN_LOOP_PROFILING_H
|
||||||
|
|
||||||
|
/* end of file */
|
Loading…
Reference in a new issue