Пример #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;

}
Пример #2
0
// Title (= explanatory text plus time totals)
CStr CProfileNodeTable::GetTitle()
{
	char buf[512];
	sprintf_s(buf, ARRAY_SIZE(buf), "Profiling Information for: %s (Time in node: %.3f msec/frame)", node->GetName(), node->GetFrameTime() * 1000.0f );
	return buf;
}
Пример #3
0
// Retrieve cell text
CStr CProfileNodeTable::GetCellText(size_t row, size_t col)
{
	CProfileNode* child;
	size_t nrchildren = node->GetChildren()->size();
	size_t nrscriptchildren = node->GetScriptChildren()->size();
	char buf[256] = "?";
	
	if (row < nrchildren)
		child = (*node->GetChildren())[row];
	else if (row < nrchildren + nrscriptchildren)
		child = (*node->GetScriptChildren())[row - nrchildren];
	else if (row > nrchildren + nrscriptchildren)
		return "!bad row!";
	else
	{
		// "unlogged" row
		if (col == 0)
			return "unlogged";
		else if (col == 1)
			return "";
		else if (col == 4)
			return "";
		
		double unlogged_time_frame = node->GetFrameTime();
		double unlogged_time_turn = node->GetTurnTime();
		double unlogged_mallocs_frame = node->GetFrameMallocs();
		double unlogged_mallocs_turn = node->GetTurnMallocs();
		CProfileNode::const_profile_iterator it;

		for (it = node->GetChildren()->begin(); it != node->GetChildren()->end(); ++it)
		{
			unlogged_time_frame -= (*it)->GetFrameTime();
			unlogged_time_turn -= (*it)->GetTurnTime();
			unlogged_mallocs_frame -= (*it)->GetFrameMallocs();
			unlogged_mallocs_turn -= (*it)->GetTurnMallocs();
		}
		for (it = node->GetScriptChildren()->begin(); it != node->GetScriptChildren()->end(); ++it)
		{
			unlogged_time_frame -= (*it)->GetFrameTime();
			unlogged_time_turn -= (*it)->GetTurnTime();
			unlogged_mallocs_frame -= (*it)->GetFrameMallocs();
			unlogged_mallocs_turn -= (*it)->GetTurnMallocs();
		}
		
		// The root node can't easily count per-turn values (since Turn isn't called until
		// halfway though a frame), so just reset them the zero to prevent weird displays
		if (!node->GetParent())
		{
			unlogged_time_turn = 0.0;
			unlogged_mallocs_turn = 0.0;
		}

		if (col == 2)
			sprintf_s(buf, ARRAY_SIZE(buf), "%.3f", unlogged_time_frame * 1000.0f);
		else if (col == 3)
			sprintf_s(buf, ARRAY_SIZE(buf), "%.1f", unlogged_mallocs_frame);
		else if (col == 5)
			sprintf_s(buf, ARRAY_SIZE(buf), "%.3f", unlogged_time_turn * 1000.f);
		else if (col == 6)
			sprintf_s(buf, ARRAY_SIZE(buf), "%.1f", unlogged_mallocs_turn);
		
		return CStr(buf);
	}
	
	switch(col)
	{
	default:
	case 0:
		return child->GetName();
		
	case 1:
		sprintf_s(buf, ARRAY_SIZE(buf), "%.1f", child->GetFrameCalls());
		break;
	case 2:
		sprintf_s(buf, ARRAY_SIZE(buf), "%.3f", child->GetFrameTime() * 1000.0f);
		break;
	case 3:
		sprintf_s(buf, ARRAY_SIZE(buf), "%.1f", child->GetFrameMallocs());
		break;
	case 4:
		sprintf_s(buf, ARRAY_SIZE(buf), "%.1f", child->GetTurnCalls());
		break;
	case 5:
		sprintf_s(buf, ARRAY_SIZE(buf), "%.3f", child->GetTurnTime() * 1000.0f);
		break;
	case 6:
		sprintf_s(buf, ARRAY_SIZE(buf), "%.1f", child->GetTurnMallocs());
		break;
	}
	return CStr(buf);
}
Пример #4
0
// Short name (= name of profile node)
CStr CProfileNodeTable::GetName()
{
	return node->GetName();
}