Profiler initial setup

This commit is contained in:
Andy Adshead 2019-01-23 20:51:21 +00:00
parent 1af6c31dc0
commit e8ded454d5
8 changed files with 121 additions and 0 deletions

View file

@ -0,0 +1,51 @@
using System;
using Ryujinx.Common.Logging;
namespace Ryujinx.Profiler
{
public class Profile
{
private static Profile ProfileInstance;
private static ProfilerSettings Settings;
private static bool ProfilingEnabled()
{
if (!Settings.Enabled)
return false;
if (ProfileInstance == null)
ProfileInstance = new Profile();
return true;
}
public static void Configure(ProfilerSettings settings)
{
Settings = settings;
}
public static void Begin(ProfileConfig config)
{
if (!ProfilingEnabled())
return;
Logger.PrintInfo(LogClass.Gpu, $"Begin {config.Name}");
}
public static void End(ProfileConfig config)
{
if (!ProfilingEnabled())
return;
Logger.PrintInfo(LogClass.Gpu, $"End {config.Name}");
}
public static void Method(ProfileConfig config, Action method)
{
// If profiling is disabled just call the method
if (!ProfilingEnabled())
method();
Begin(config);
method();
End(config);
}
}
}

View file

@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Ryujinx.Profiler
{
public struct ProfileConfig
{
public string Name;
}
public static class Profiles
{
public static class CPU
{
public static ProfileConfig Test = new ProfileConfig()
{
Name = "Test",
};
}
}
}

View file

@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<RuntimeIdentifiers>win10-x64;osx-x64;linux-x64</RuntimeIdentifiers>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Ryujinx.Common\Ryujinx.Common.csproj" />
</ItemGroup>
</Project>

View file

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Ryujinx.Profiler
{
public class ProfilerSettings
{
public bool Enabled = true;
public bool FileDumpEnabled = false;
public string DumpLocation = "";
}
}

View file

@ -23,6 +23,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Luea", "Ryujinx.LLE\Luea.cs
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ryujinx.Common", "Ryujinx.Common\Ryujinx.Common.csproj", "{5FD4E4F6-8928-4B3C-BE07-28A675C17226}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ryujinx.Profiler", "Ryujinx.Profiler\Ryujinx.Profiler.csproj", "{4E69B67F-8CA7-42CF-A9E1-CCB0915DFB34}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -69,6 +71,10 @@ Global
{5FD4E4F6-8928-4B3C-BE07-28A675C17226}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5FD4E4F6-8928-4B3C-BE07-28A675C17226}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5FD4E4F6-8928-4B3C-BE07-28A675C17226}.Release|Any CPU.Build.0 = Release|Any CPU
{4E69B67F-8CA7-42CF-A9E1-CCB0915DFB34}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4E69B67F-8CA7-42CF-A9E1-CCB0915DFB34}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4E69B67F-8CA7-42CF-A9E1-CCB0915DFB34}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4E69B67F-8CA7-42CF-A9E1-CCB0915DFB34}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View file

@ -10,6 +10,7 @@ using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using Ryujinx.Profiler;
namespace Ryujinx
{
@ -62,6 +63,15 @@ namespace Ryujinx
}
}
string profilePath = parser.Value("Profile_Dump_Path");
Profile.Configure(new ProfilerSettings()
{
Enabled = Convert.ToBoolean(parser.Value("Profiling_Enabled")),
FileDumpEnabled = profilePath != "",
DumpLocation = profilePath,
});
SystemLanguage SetLanguage = Enum.Parse<SystemLanguage>(parser.Value("System_Language"));
device.System.State.SetLanguage(SetLanguage);

View file

@ -22,6 +22,12 @@ Logging_Enable_Error = true
#Filtered log classes, seperated by ", ", eg. `Logging_Filtered_Classes = Loader, ServiceFS`
Logging_Filtered_Classes =
#Enable profiling
Profiling_Enabled = true
#Set profile file dump location, if blank file dumping disabled. (e.g. `ProfileDump.txt`)
Profile_Dump_Path = ProfileDump.txt
#System Language list: https://gist.github.com/HorrorTroll/b6e4a88d774c3c9b3bdf54d79a7ca43b
#Change System Language
System_Language = AmericanEnglish

View file

@ -17,6 +17,7 @@
<ProjectReference Include="..\Ryujinx.Common\Ryujinx.Common.csproj" />
<ProjectReference Include="..\Ryujinx.Graphics\Ryujinx.Graphics.csproj" />
<ProjectReference Include="..\Ryujinx.HLE\Ryujinx.HLE.csproj" />
<ProjectReference Include="..\Ryujinx.Profiler\Ryujinx.Profiler.csproj" />
</ItemGroup>
<ItemGroup>