示例#1
0
Void CDebugProfView::Format( )
{
	DebugProfile( "CDebugProfView::Format" );
	
	String parentName;

#ifndef SETUP_USE_PROF
	m_Buffer[0] = 0;
	return ;
#endif

	Char* buffer = m_Buffer.GetBuffer();
	Int32 s = m_Buffer.GetItemCount();
	Int32 off;
	UInt32 frameCount = CoreManager.GetDebugProf().GetSampledFrameCount();

	parentName = m_CurrentNode->GetName();

	off = StringSetFormattedText( buffer, s,"| Profiling Data | Depth Level: %d    \n" \
											"| Parent: %s \n" \
											"-----------------------------------------------------\n", 
											m_NavigationHistory.GetItemCount(), parentName );
	buffer += off;

	Float32 selfTotalTime = 0.0f;
	Float32 parentTotalTime = 0.0f;

	if( frameCount >= PROFVIEW_FRAMEDELAY )
	{
        CProfileNode* childNode = NULL;

		parentTotalTime = m_CurrentNode->GetTotalSamplingTime() / (Float32) frameCount; 
	
		m_EntryCount = 0;

		Float32 time;
		Int32 percent;

        childNode = m_CurrentNode->GetChild();
		while( childNode )
		{
			time = childNode->GetTotalSamplingTime();
			time = time / (Float32) frameCount; 

			selfTotalTime += time;
			childNode = childNode->GetSibling();
		}

		childNode = m_CurrentNode->GetChild();
		while( childNode )
		{
			time = childNode->GetTotalSamplingTime()/ (Float32) frameCount;
			if( parentTotalTime > 0.0f )
				percent = ( Int32 ) ( time / parentTotalTime * 100.0f );
			else
				percent = 0;

			if( m_EntryCount != m_SelectionMark )
				off = StringSetFormattedText( buffer, s, "|  %s : %.5f ms %d %%\n", childNode->GetName(), time * 1000.0f, percent );
			else
				off = StringSetFormattedText( buffer, s, "|>> %s : %.5f ms %d %%\n", childNode->GetName(), time * 1000.0f, percent );

			buffer += off;

			m_EntryCount++;
			childNode = childNode->GetSibling();
		}
	}
	else
	{
		off = StringSetFormattedText( buffer, s, "Sampling...\n");
		buffer += off;
	}

	Float32 totalTime = parentTotalTime;
	Float32 profiledTime = selfTotalTime;
	Float32 unProfiledTime = parentTotalTime - selfTotalTime;
	if( unProfiledTime < 0 )
		unProfiledTime = 0;

	off = StringSetFormattedText( buffer, s, "-----------------------------------------------------\n");
	buffer += off;
	off = StringSetFormattedText( buffer, s, "| Total time: %.5f ms \n", totalTime * 1000.0f );
	buffer += off;
	off = StringSetFormattedText( buffer, s, "| Profiled time: %.5f ms \n", profiledTime * 1000.0f );
	buffer += off;
	off = StringSetFormattedText( buffer, s, "| UnProfiled time: %.5f ms \n", unProfiledTime * 1000.0f );
	buffer += off;

}