예제 #1
0
void FProfilerManager::LoadProfilerCapture( const FString& ProfilerCaptureFilepath, const bool bAdd /*= false*/ )
{
	// deselect the active session
	if (ActiveSession.IsValid())
	{
		SessionManager->SelectSession(NULL);
	}

	if( bAdd == false )
	{
		ClearStatsAndInstances();
	}

	FProfilerSessionRef ProfilerSession = MakeShareable( new FProfilerSession( ProfilerCaptureFilepath ) );
	auto Var = ProfilerSession->AsShared();
	const FGuid ProfilerInstanceID = ProfilerSession->GetInstanceID();

	ProfilerSession->
		SetOnCaptureFileProcessed( FProfilerSession::FCaptureFileProcessedDelegate::CreateSP( this, &FProfilerManager::ProfilerSession_OnCaptureFileProcessed ) )
		.SetOnAddThreadTime( FProfilerSession::FAddThreadTimeDelegate::CreateSP( this, &FProfilerManager::ProfilerSession_OnAddThreadTime ) );

	ProfilerSessionInstances.Add( ProfilerInstanceID, ProfilerSession );
	{
		PROFILER_SCOPE_LOG_TIME( TEXT( "ProfilerClient->LoadCapture" ), );
		ProfilerClient->LoadCapture( ProfilerCaptureFilepath, ProfilerInstanceID );
	}

	SessionInstancesUpdatedEvent.Broadcast();
	ProfilerType = EProfilerSessionTypes::StatsFile;
	
	GetProfilerWindow()->ManageEventGraphTab( ProfilerInstanceID, true, ProfilerSession->GetName() );
	SetViewMode( EProfilerViewMode::LineIndexBased );
}
예제 #2
0
void FProfilerManager::SessionManager_OnInstanceSelectionChanged()
{
	const ISessionInfoPtr& SelectedSession = SessionManager->GetSelectedSession();
	const bool SessionIsValid = SelectedSession.IsValid() && (SelectedSession->GetSessionOwner() == FPlatformProcess::UserName(true));

	if( ActiveSession != SelectedSession || FProfilerManager::GetSettings().bSingleInstanceMode )
	{
		ClearStatsAndInstances();

		if (SessionIsValid)
		{
			ActiveSession = SelectedSession;
			ProfilerClient->Subscribe( ActiveSession->GetSessionId() );
			ProfilerType = EProfilerSessionTypes::Live;
			SetViewMode( EProfilerViewMode::LineIndexBased );
		}
		else
		{
			ActiveSession = nullptr;
			ProfilerType = EProfilerSessionTypes::InvalidOrMax;
		}
	}

	if( ActiveSession.IsValid() )
	{
		// Track all selected session instances.
		SessionManager->GetSelectedInstances( SelectedSessionInstances );
		const int32 NumSelectedInstances = SelectedSessionInstances.Num();
		const int32 NumInstances = FMath::Min( NumSelectedInstances, FProfilerManager::GetSettings().bSingleInstanceMode ? 1 : NumSelectedInstances );

		for( int32 Index = 0; Index < NumInstances; ++Index )
		{
			const ISessionInstanceInfoPtr SessionInstanceInfo = SelectedSessionInstances[Index];
			const FGuid ProfilerInstanceID = SessionInstanceInfo->GetInstanceId();
			const bool bAlreadyAdded = ProfilerSessionInstances.Contains( ProfilerInstanceID );

			if( !bAlreadyAdded )
			{
				FProfilerSessionRef ProfilerSession = MakeShareable( new FProfilerSession( SessionInstanceInfo ) );
				ProfilerSession->SetOnAddThreadTime( FProfilerSession::FAddThreadTimeDelegate::CreateSP( this, &FProfilerManager::ProfilerSession_OnAddThreadTime ) );

				ProfilerSessionInstances.Add( ProfilerSession->GetInstanceID(), ProfilerSession );
				ProfilerClient->Track( ProfilerInstanceID );
				TSharedPtr<SProfilerWindow> ProfilerWindow = GetProfilerWindow();
				if (ProfilerWindow.IsValid())
				{
					ProfilerWindow->ManageEventGraphTab(ProfilerInstanceID, true, ProfilerSession->GetName());
				}
			}
		}
	}

	SessionInstancesUpdatedEvent.Broadcast();
}
예제 #3
0
void FProfilerManager::DataGraph_OnSelectionChangedForIndex( uint32 FrameStartIndex, uint32 FrameEndIndex )
{
	PROFILER_SCOPE_LOG_TIME( TEXT( "FProfilerManager::DataGraph_OnSelectionChangedForIndex" ), nullptr );

	for( auto It = GetProfilerInstancesIterator(); It; ++It )
	{
		FProfilerSessionRef ProfilerSession = It.Value();
	
		FEventGraphDataRef EventGraphDataAverage = ProfilerSession->CreateEventGraphData( FrameStartIndex, FrameEndIndex, EEventGraphTypes::Average );
		FEventGraphDataRef EventGraphDataMaximum = ProfilerSession->CreateEventGraphData( FrameStartIndex, FrameEndIndex, EEventGraphTypes::Maximum );

		GetProfilerWindow()->UpdateEventGraph( ProfilerSession->GetInstanceID(), EventGraphDataAverage, EventGraphDataMaximum, false );
	}
}
예제 #4
0
void FProfilerManager::CloseAllEventGraphTabs()
{
	TSharedPtr<SProfilerWindow> ProfilerWindowPtr = GetProfilerWindow();
	if( ProfilerWindowPtr.IsValid() )
	{
		// Iterate through all profiler sessions.
		for( auto It = GetProfilerInstancesIterator(); It; ++It )
		{
			FProfilerSessionRef ProfilerSession = It.Value();
			ProfilerWindowPtr->ManageEventGraphTab( ProfilerSession->GetInstanceID(), false, TEXT("") );
		}

		ProfilerWindowPtr->ProfilerMiniView->Reset();
	}
}