diff --git a/code/ryzom/client/src/main_loop.cpp b/code/ryzom/client/src/main_loop.cpp index 8cccb99f2..bd79d3490 100644 --- a/code/ryzom/client/src/main_loop.cpp +++ b/code/ryzom/client/src/main_loop.cpp @@ -150,7 +150,9 @@ #include "nel/gui/lua_manager.h" #include "nel/gui/group_table.h" +// pulled from main_loop.cpp #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 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? @@ -415,119 +411,8 @@ void buildCameraClippingPyramid (vector &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 strs; - Driver->endProfileVBHardLock(strs); - nlinfo("Profile VBLock"); - nlinfo("**************"); - for(uint i=0;iprofileVBHardAllocation(strs); - for(uint i=0;iendProfileIBLock(strs); - nlinfo("Profile Index Buffer Lock"); - nlinfo("**************"); - for(uint i=0;iprofileIBAllocation(strs); - for(uint i=0;istartProfileVBHardLock(); - Driver->startProfileIBLock(); - } -} //--------------------------------------------------- diff --git a/code/ryzom/client/src/profiling.cpp b/code/ryzom/client/src/profiling.cpp new file mode 100644 index 000000000..54f830211 --- /dev/null +++ b/code/ryzom/client/src/profiling.cpp @@ -0,0 +1,159 @@ +// Ryzom - MMORPG Framework +// 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 . + +#include "profiling.h" + +// NeL includes +#include + +// 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 strs; + Driver->endProfileVBHardLock(strs); + nlinfo("Profile VBLock"); + nlinfo("**************"); + for(uint i=0;iprofileVBHardAllocation(strs); + for(uint i=0;iendProfileIBLock(strs); + nlinfo("Profile Index Buffer Lock"); + nlinfo("**************"); + for(uint i=0;iprofileIBAllocation(strs); + for(uint i=0;istartProfileVBHardLock(); + Driver->startProfileIBLock(); + } +} + +/* end of file */ \ No newline at end of file diff --git a/code/ryzom/client/src/profiling.h b/code/ryzom/client/src/profiling.h new file mode 100644 index 000000000..cb7a55495 --- /dev/null +++ b/code/ryzom/client/src/profiling.h @@ -0,0 +1,36 @@ +// Ryzom - MMORPG Framework +// 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 . + +#ifndef CL_MAIN_LOOP_PROFILING_H +#define CL_MAIN_LOOP_PROFILING_H + +#include + +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 */ \ No newline at end of file