当前位置: 首页>>代码示例>>C++>>正文


C++ Profiler::Advance方法代码示例

本文整理汇总了C++中Profiler::Advance方法的典型用法代码示例。如果您正苦于以下问题:C++ Profiler::Advance方法的具体用法?C++ Profiler::Advance怎么用?C++ Profiler::Advance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Profiler的用法示例。


在下文中一共展示了Profiler::Advance方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Render

void SoundProfileWindow::Render( bool hasFocus )
{
    DarwiniaWindow::Render( hasFocus );
#ifdef PROFILER_ENABLED
    int xPos = m_x + 15;
    int yPos = m_y + 40;
    int yDif = 13;
    int textSize = DEF_FONT_SIZE;

	//
    // Print Main Profiles

	float total = 0.0f;

	{
		Profiler *profiler = g_app->m_soundSystem->m_mainProfiler;
		float maxTime = profiler->m_rootElement->GetMaxChildTime() * 1000.0f;

		int i = profiler->m_rootElement->m_children.StartOrderedWalk();
		while (i != -1)
		{
			ProfiledElement *pe = profiler->m_rootElement->m_children[i];
			float time = float( pe->m_lastTotalTime * 1000.0f );
			float timePerCall = 0.0f;
			if( pe->m_lastNumCalls > 0 )
			{
				timePerCall = time/(float)pe->m_lastNumCalls;
			}
			char caption[256];
			sprintf( caption, "%-28s:%3dx%2.1f = %2.0f  %2.0f",
					 pe->m_name,
					 pe->m_lastNumCalls,
					 timePerCall,
					 time,
 					 pe->m_historyTotalTime * 1000.0 / pe->m_historyNumSeconds);

			float colour = 0.5f + 0.5f * time / maxTime;
			glColor4f( colour, colour, colour, 1.0f );

			g_editorFont.DrawText2D( xPos, yPos+=yDif, textSize, caption );

			total += time;

			i = profiler->m_rootElement->m_children.GetNextOrderedIndex();
		}

		ProfiledElement *pe = g_app->m_profiler->m_rootElement->m_children.GetData("Advance SoundSystem");
		float advanceTime = pe->m_lastTotalTime * 1000.0f;
		float other = advanceTime - total;
		if( other < 0 ) other = 0;
		float colour = 0.5f + 0.5f * other / maxTime;
		glColor4f( colour, colour, colour, 1.0f );
		g_editorFont.DrawText2D( xPos, yPos+=yDif, textSize, "Other         :        = %2.0f", other );
		total += other;
	}


	yPos = m_y + 300;


	//
    // Print Event Profiles

	{
		Profiler *profiler = g_app->m_soundSystem->m_eventProfiler;
		float maxTime = profiler->m_rootElement->GetMaxChildTime() * 1000.0f;
		float total = 0.0f;
		if (maxTime < 1e-6) maxTime = 1e-6;

		int i = profiler->m_rootElement->m_children.StartOrderedWalk();
		while (i != -1)
		{
			ProfiledElement *pe = profiler->m_rootElement->m_children[i];
			float time = float( pe->m_lastTotalTime * 1000.0f );
			float timePerCall = 0.0f;
			if( pe->m_lastNumCalls > 0 )
			{
				timePerCall = time/(float)pe->m_lastNumCalls;
			}
			char caption[256];
			sprintf( caption, "%-28s:%3dx%2.1f = %2.0f  %2.0f",
					 pe->m_name,
					 pe->m_lastNumCalls,
					 timePerCall,
					 time,
					 pe->m_historyTotalTime * 1000.0 / pe->m_historyNumSeconds);

			float colour = 0.5f + 0.5f * time / maxTime;
			glColor4f( colour, colour, colour, 1.0f );

			g_editorFont.DrawText2D( xPos, yPos+=yDif, textSize, caption );

			total += time;

			i = profiler->m_rootElement->m_children.GetNextOrderedIndex();
		}
	}


	//
//.........这里部分代码省略.........
开发者ID:gene9,项目名称:Darwinia-and-Multiwinia-Source-Code,代码行数:101,代码来源:sound_profile_window.cpp


注:本文中的Profiler::Advance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。