MCPcopy Create free account
hub / github.com/DaedalusX64/daedalus / Update

Method Update

Source/Utility/Profiler.cpp:209–301  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

207
208
209void CProfilerImpl::Update()
210{
211 DAEDALUS_ASSERT( mActiveCallstacks.size() == mActiveItems.size(), "Why are there different numbers of callstacks/items?" );
212
213 u64 now = GetNow();
214 for( u32 i = 0; i < mActiveCallstacks.size(); ++i )
215 {
216 mActiveCallstacks[ i ]->StopTiming( now );
217 }
218
219 u64 total_root_time = 0;
220 if( mActiveCallstacks.size() > 0 )
221 {
222 total_root_time = mActiveCallstacks[ 0 ]->GetTotalTime();
223 }
224
225 const char * const TERMINAL_SAVE_CURSOR = "\033[s";
226// const char * const TERMINAL_RESTORE_CURSOR = "\033[u";
227// const char * const TERMINAL_TOP_LEFT = "\033[2A\033[2K";
228 const char * const TERMINAL_TOP_LEFT = "\033[H";
229 const char * const TERMINAL_ERASE_TO_EOL = "\033[K";
230// const char * const TERMINAL_ERASE_TO_EOS = "\033[J";
231
232 printf( TERMINAL_SAVE_CURSOR );
233 printf( TERMINAL_TOP_LEFT );
234
235 std::vector< const CProfileCallstack * > active_callstacks;
236 for( CallstackStatsMap::const_iterator it = mCallstackStatsMap.begin(); it != mCallstackStatsMap.end(); ++it )
237 {
238 const CProfileCallstack * callstack = it->second;
239 if( callstack->GetHitCount() > 0 )
240 {
241 active_callstacks.push_back( callstack );
242 }
243 }
244
245 std::sort( active_callstacks.begin(), active_callstacks.end(), SortByCallstack() );
246
247 // 0 1 2 3 4 5 6 7 8
248 // 012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
249 printf( " Function Time us Parent Overall Hits\n" );
250
251 for( u32 i = 0; i < active_callstacks.size(); ++i )
252 {
253 const CProfileCallstack * callstack = active_callstacks[ i ];
254
255 u64 parent_time = 0;
256 if ( const CProfileCallstack * parent = callstack->GetParent() )
257 {
258 parent_time = parent->GetTotalTime();
259 }
260
261 u32 hit_count = callstack->GetHitCount();
262
263 // Display details on this item
264 u32 depth = callstack->GetDepth();
265 u32 total_us = u32( callstack->GetTotalTime() * 1000.0f * 1000.0f * mFrequencyInv );
266

Callers 1

Calls 13

GetNowFunction · 0.85
SortByCallstackClass · 0.85
PadFunction · 0.85
sizeMethod · 0.80
StopTimingMethod · 0.80
GetTotalTimeMethod · 0.80
GetParentMethod · 0.80
GetDepthMethod · 0.80
GetBackMethod · 0.80
StartTimingMethod · 0.80
GetHitCountMethod · 0.45
GetNameMethod · 0.45

Tested by

no test coverage detected