예제 #1
0
		public static void dumpRecursive( CProfileIterator profileIterator, int spacing )
		{
			profileIterator.First();
			if( profileIterator.Is_Done() )
				return;

			float accumulated_time = 0, parent_time = profileIterator.Is_Root() ? CProfileManager.Get_Time_Since_Reset() : profileIterator.Get_Current_Parent_Total_Time();
			int i;
			int frames_since_reset = CProfileManager.Get_Frame_Count_Since_Reset();
			for( i = 0; i < spacing; i++ ) Console.WriteLine( "." );
			Console.WriteLine( "----------------------------------\n" );
			for( i = 0; i < spacing; i++ ) Console.WriteLine( "." );
			Console.WriteLine( "Profiling: " + profileIterator.Get_Current_Parent_Name()
				+ " (total running time: " + parent_time + " ms) ---\n" );
			float totalTime = 0;


			int numChildren = 0;

			for( i = 0; !profileIterator.Is_Done(); i++, profileIterator.Next() )
			{
				numChildren++;
				float current_total_time = profileIterator.Get_Current_Total_Time();
				accumulated_time += current_total_time;
				float fraction = parent_time > btScalar.SIMD_EPSILON ? ( current_total_time / parent_time ) * 100 : 0;
				{
					int s; for( s = 0; s < spacing; s++ ) Console.WriteLine( "." );
				}
				Console.WriteLine( 
					i
					+ "-- "
					+ profileIterator.Get_Current_Name()
					+ "(" 
					+ fraction
					+ " %) :: "
					+ ( current_total_time / (double)frames_since_reset )
					+ " ms / frame("
					+ profileIterator.Get_Current_Total_Calls() 
					+ " calls )"
					);
				totalTime += current_total_time;
				//recurse into children
			}

			if( parent_time < accumulated_time )
			{
				//Console.WriteLine("what's wrong\n");
			}
			for( i = 0; i < spacing; i++ ) Console.WriteLine( "." );
			Console.WriteLine( "Unaccounted:  ("
				+ ( parent_time > btScalar.SIMD_EPSILON 
				  ? ( ( parent_time - accumulated_time ) / parent_time ) * 100 
				  : 0 )
				+ " %%) :: "
				+ ( parent_time - accumulated_time )
				+ " ms\n" );

			for( i = 0; i < numChildren; i++ )
			{
				profileIterator.Enter_Child( i );
				dumpRecursive( profileIterator, spacing + 3 );
				profileIterator.Enter_Parent();
			}
		}