1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
4 // This source file has been modified by the following contributors:
5 // Copyright (C) 2013-2014 Jan BOON (Kaetemi) <jan.boon@kaetemi.be>
7 // This program is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU Affero General Public License as
9 // published by the Free Software Foundation, either version 3 of the
10 // License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU Affero General Public License for more details.
17 // You should have received a copy of the GNU Affero General Public License
18 // along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #include "profiling.h"
24 #include <nel/3d/u_driver.h>
28 #include "sound_manager.h"
33 using namespace NLMISC
;
39 extern UDriver
*Driver
;
44 bool Profiling
= false; // Are we in Profile mode?
45 uint ProfileNumFrame
= 0;
46 bool WantProfiling
= false;
47 bool ProfilingVBLock
= false;
48 bool WantProfilingVBLock
= false;
50 // ********************************************************************
52 /// Test Profiling and run?
53 void testLaunchProfile()
58 // comes from ActionHandler
65 NLMISC::CHTimer::startBench();
69 SoundMngr
->getMixer()->startDriverBench();
77 SoundMngr
->getMixer()->endDriverBench();
78 NLMISC::CHTimer::endBench();
82 // Display and save profile to a File.
84 CFileDisplayer
fileDisplayer(NLMISC::CFile::findNewFile(getLogDirectory() + "profile.log"));
85 CStdDisplayer stdDisplayer
;
86 log
.addDisplayer(&fileDisplayer
);
87 log
.addDisplayer(&stdDisplayer
);
89 NLMISC::CHTimer::displayHierarchicalByExecutionPathSorted(&log
, CHTimer::TotalTime
, true, 48, 2);
90 NLMISC::CHTimer::displayHierarchical(&log
, true, 48, 2);
91 NLMISC::CHTimer::displayByExecutionPath(&log
, CHTimer::TotalTime
);
92 NLMISC::CHTimer::display(&log
, CHTimer::TotalTime
);
93 NLMISC::CHTimer::display(&log
, CHTimer::TotalTimeWithoutSons
);
94 Driver
->displayBench(&log
);
97 SoundMngr
->getMixer()->displayDriverBench(&log
);
102 #endif // #ifdef _PROFILE_ON_
105 // ********************************************************************
107 /// Test ProfilingVBLock and run?
108 void testLaunchProfileVBLock()
110 // If running, must stop for this frame.
113 std::vector
<string
> strs
;
114 Driver
->endProfileVBHardLock(strs
);
115 nlinfo("Profile VBLock");
116 nlinfo("**************");
117 for(uint i
=0;i
<strs
.size();i
++)
119 nlinfo(strs
[i
].c_str());
121 ProfilingVBLock
= false;
123 // Display additional info on allocated VBHards
124 nlinfo("VBHard list");
125 nlinfo("**************");
126 Driver
->profileVBHardAllocation(strs
);
127 for(uint i
=0;i
<strs
.size();i
++)
129 nlinfo(strs
[i
].c_str());
132 Driver
->endProfileIBLock(strs
);
133 nlinfo("Profile Index Buffer Lock");
134 nlinfo("**************");
135 for(uint i
=0;i
<strs
.size();i
++)
137 nlinfo(strs
[i
].c_str());
139 ProfilingVBLock
= false;
141 // Display additional info on allocated VBHards
143 nlinfo("Index Buffer list");
144 nlinfo("**************");
145 Driver->profileIBAllocation(strs);
146 for(uint i=0;i<strs.size();i++)
148 nlinfo(strs[i].c_str());
153 // comes from ActionHandler
154 if(WantProfilingVBLock
)
156 WantProfilingVBLock
= false;
157 ProfilingVBLock
= true;
158 Driver
->startProfileVBHardLock();
159 Driver
->startProfileIBLock();