void EngineProfiler::onEndOfFrame() {

	Console* sharedDeveloperConsole = Console::getSharedDeveloperConsole();

	for ( size_t i = 0; i < NUM_PROFILE_CATEGORIES; ++i ) {

		ProfileResult& profileResult = m_profileResults[i];

		if ( profileResult.m_durationMeasuredCurrentFrame > 0.0f ) {

			profileResult.m_numFramesMeasured++;
			profileResult.m_totalDurationMeasured += profileResult.m_durationMeasuredCurrentFrame;

			if ( m_shouldReportCurrentProfileResultsAtEndOfFrame ) {

				std::string consoleLineText = getStringForEnumValue( profileResult.m_profileCategory );

				consoleLineText += " - Duration Current Frame: ";
				std::string durationThisFrameAsString = std::to_string( static_cast<long double>( profileResult.m_durationMeasuredCurrentFrame ) ); 
				consoleLineText += durationThisFrameAsString;

				consoleLineText += " Average Time Per Frame: ";
				float averageTimePerFrame = profileResult.m_totalDurationMeasured / static_cast<float>( profileResult.m_numFramesMeasured );
				std::string averageTimePerFrameAsString = std::to_string( static_cast<long double>( averageTimePerFrame ) );
				consoleLineText += averageTimePerFrameAsString;

				sharedDeveloperConsole->addStringToConsole( consoleLineText, ConsoleTextColorForProfiler );
			}
		}

		profileResult.m_durationMeasuredCurrentFrame = 0.0f;
	}

	m_shouldReportCurrentProfileResultsAtEndOfFrame = false;
}
// DEBUG
void TimeSystem::outputClocksToConsoleDepthFirst() {

	Console* sharedConsole = Console::getSharedDeveloperConsole();
	cbengine::Vector4<float> textColor( 0.90f, 0.40f, 0.67f, 1.0f );
	std::string consoleLine = "Depth First Traversal Of Clocks";

	sharedConsole->addStringToConsole( consoleLine, textColor );
	
	m_masterClock->outputSelfAndChildrenDepthFirstToConsole();
}