예제 #1
0
void FProfilerManager::LoadRawStatsFile( const FString& RawStatsFileFileath )
{
	if( ActiveSession.IsValid() )
	{
		SessionManager->SelectSession( NULL );
	}
	ClearStatsAndInstances();

	TSharedRef<FRawProfilerSession> ProfilerSession = MakeShareable( new FRawProfilerSession( RawStatsFileFileath ) );
	const FGuid ProfilerInstanceID = ProfilerSession->GetInstanceID();
	ProfilerSessionInstances.Add( ProfilerInstanceID, ProfilerSession );

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

	ProfilerSessionInstances.Add( ProfilerInstanceID, ProfilerSession );

	ProfilerSession->PrepareLoading();
	RequestFilterAndPresetsUpdateEvent.Broadcast();
	//ProfilerSession_OnCaptureFileProcessed( ProfilerInstanceID );
	bHasCaptureFileFullyProcessed = true;
	//TrackDefaultStats();

	SessionInstancesUpdatedEvent.Broadcast();
	ProfilerType = EProfilerSessionTypes::StatsFileRaw;
	
	GetProfilerWindow()->ManageEventGraphTab( ProfilerInstanceID, true, ProfilerSession->GetName() );
	SetViewMode( EProfilerViewMode::ThreadViewTimeBased );

	GetProfilerWindow()->GraphPanel->ThreadView->AttachProfilerStream( ProfilerSession->GetStream() );
}
예제 #2
0
void FProfilerManager::ProfilerClient_OnLoadStarted( const FGuid& InstanceID )
{
	const FProfilerSessionRef* ProfilerSession = FindSessionInstance( InstanceID );
	if( ProfilerSession && GetProfilerWindow().IsValid())
	{
		const FString Description = (*ProfilerSession)->GetName();

		// Display the notification that a file is being loaded.
		GetProfilerWindow()->ManageLoadingProgressNotificationState( (*ProfilerSession)->GetName(), EProfilerNotificationTypes::LoadingOfflineCapture, ELoadingProgressStates::Started, 0.0f );
	}
}
예제 #3
0
void FProfilerManager::ProfilerClient_OnLoadCompleted( const FGuid& InstanceID )
{
	// Inform that the file has been loaded and we can hide the notification.
	const FProfilerSessionRef* ProfilerSession = FindSessionInstance( InstanceID );
	if( ProfilerSession && GetProfilerWindow().IsValid())
	{
		(*ProfilerSession)->LoadComplete();

		// Update the notification that a file has been loaded, to be precise it should be loaded on the next tick...
		GetProfilerWindow()->ManageLoadingProgressNotificationState( (*ProfilerSession)->GetName(), EProfilerNotificationTypes::LoadingOfflineCapture, ELoadingProgressStates::Loaded, 1.0f );
	}
}
예제 #4
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 );
}
예제 #5
0
void FProfilerManager::ProfilerSession_OnAddThreadTime( int32 FrameIndex, const TMap<uint32, float>& ThreadMS, const FProfilerStatMetaDataRef& StatMetaData )
{
	TSharedPtr<SProfilerWindow> ProfilerWindowPtr = GetProfilerWindow();
	if( ProfilerWindowPtr.IsValid() )
	{
		ProfilerWindowPtr->ProfilerMiniView->AddThreadTime( FrameIndex, ThreadMS, StatMetaData );
	}
}
예제 #6
0
void FProfilerManager::ProfilerSession_OnCaptureFileProcessed( const FGuid ProfilerInstanceID )
{
	const FProfilerSessionRef* ProfilerSession = FindSessionInstance( ProfilerInstanceID );
	if( ProfilerSession && ProfilerWindow.IsValid())
	{
		GetProfilerWindow()->UpdateEventGraph( ProfilerInstanceID, (*ProfilerSession)->GetEventGraphDataAverage(), (*ProfilerSession)->GetEventGraphDataMaximum(), true );
		bHasCaptureFileFullyProcessed = true;
	}
}
예제 #7
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();
}
예제 #8
0
void FProfilerManager::ProfilerSession_OnCaptureFileProcessed( const FGuid ProfilerInstanceID )
{
	const FProfilerSessionRef* ProfilerSession = FindSessionInstance( ProfilerInstanceID );
	if( ProfilerSession && ProfilerWindow.IsValid())
	{
		TrackDefaultStats();

		RequestFilterAndPresetsUpdateEvent.Broadcast();

		GetProfilerWindow()->UpdateEventGraph( ProfilerInstanceID, (*ProfilerSession)->GetEventGraphDataAverage(), (*ProfilerSession)->GetEventGraphDataMaximum(), true );
		bHasCaptureFileFullyProcessed = true;
	}
}
예제 #9
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 );
	}
}
예제 #10
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();
	}
}
예제 #11
0
void FProfilerManager::ProfilerClient_OnProfilerData( const FGuid& InstanceID, const FProfilerDataFrame& Content, const float DataLoadingProgress )
{
	SCOPE_CYCLE_COUNTER(STAT_PM_HandleProfilerData);

	const FProfilerSessionRef* ProfilerSession = FindSessionInstance( InstanceID );
	if( ProfilerSession && ProfilerWindow.IsValid())
	{
		(*ProfilerSession)->UpdateProfilerData( Content );
		// Game thread should always be enabled.
		TrackDefaultStats();

		// Update the notification that a file is being loaded.
		GetProfilerWindow()->ManageLoadingProgressNotificationState( (*ProfilerSession)->GetName(), EProfilerNotificationTypes::LoadingOfflineCapture, ELoadingProgressStates::InProgress, DataLoadingProgress );
	}
}