Variable update rate
This commit is contained in:
parent
da55a9813c
commit
db0a2fd344
6 changed files with 52 additions and 22 deletions
|
@ -11,7 +11,7 @@ namespace Ryujinx.Profiler
|
|||
private Stopwatch SW;
|
||||
internal ConcurrentDictionary<ProfileConfig, TimingInfo> Timers;
|
||||
|
||||
private object sessionLock = new object();
|
||||
private readonly object sessionLock = new object();
|
||||
private int sessionCounter = 0;
|
||||
|
||||
public InternalProfile()
|
||||
|
|
|
@ -77,5 +77,10 @@ namespace Ryujinx.Profiler
|
|||
return new Dictionary<ProfileConfig, TimingInfo>();
|
||||
return ProfileInstance.GetProfilingData();
|
||||
}
|
||||
|
||||
public static float GetUpdateRate()
|
||||
{
|
||||
return Settings.UpdateRate;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,5 +9,6 @@ namespace Ryujinx.Profiler
|
|||
public bool Enabled = true;
|
||||
public bool FileDumpEnabled = false;
|
||||
public string DumpLocation = "";
|
||||
public float UpdateRate = 0.1f;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ namespace Ryujinx
|
|||
private bool visible = true, initComplete = false;
|
||||
public bool visibleChanged;
|
||||
private FontService fontService;
|
||||
private List<KeyValuePair<ProfileConfig, TimingInfo>> profileData;
|
||||
private List<KeyValuePair<ProfileConfig, TimingInfo>> rawPofileData, profileData;
|
||||
|
||||
private float scrollPos = 0;
|
||||
private float minScroll = 0, maxScroll = 0;
|
||||
|
@ -36,8 +36,8 @@ namespace Ryujinx
|
|||
private IComparer<KeyValuePair<ProfileConfig, TimingInfo>> sortAction;
|
||||
|
||||
private string FilterText = "";
|
||||
private double BackspaceDownTime = -1;
|
||||
private bool BackspaceDown = false, prevBackspaceDown = false, regexEnabled = false;
|
||||
private double BackspaceDownTime, UpdateTimer;
|
||||
private bool BackspaceDown = false, prevBackspaceDown = false, regexEnabled = false, ProfileUpdated = false;
|
||||
|
||||
public ProfileWindow()
|
||||
: base(400, 720)
|
||||
|
@ -45,6 +45,10 @@ namespace Ryujinx
|
|||
Location = new Point(DisplayDevice.Default.Width - 400, (DisplayDevice.Default.Height - 720) / 2);
|
||||
Title = "Profiler";
|
||||
sortAction = null;
|
||||
BackspaceDownTime = 0;
|
||||
|
||||
// Large number to force an update on first update
|
||||
UpdateTimer = 0xFFFF;
|
||||
}
|
||||
|
||||
#region Public Methods
|
||||
|
@ -137,32 +141,47 @@ namespace Ryujinx
|
|||
}
|
||||
prevBackspaceDown = BackspaceDown;
|
||||
|
||||
// Filtering
|
||||
profileData = Profile.GetProfilingData().ToList();
|
||||
if (sortAction != null)
|
||||
// Get timing data if enough time has passed
|
||||
UpdateTimer += e.Time;
|
||||
if (UpdateTimer > Profile.GetUpdateRate())
|
||||
{
|
||||
profileData.Sort(sortAction);
|
||||
UpdateTimer %= Profile.GetUpdateRate();
|
||||
rawPofileData = Profile.GetProfilingData().ToList();
|
||||
ProfileUpdated = true;
|
||||
}
|
||||
|
||||
if (regexEnabled)
|
||||
|
||||
// Filtering
|
||||
if (ProfileUpdated)
|
||||
{
|
||||
try
|
||||
profileData = rawPofileData;
|
||||
|
||||
if (sortAction != null)
|
||||
{
|
||||
Regex filterRegex = new Regex(FilterText, RegexOptions.IgnoreCase);
|
||||
if (FilterText != "")
|
||||
profileData.Sort(sortAction);
|
||||
}
|
||||
|
||||
if (regexEnabled)
|
||||
{
|
||||
try
|
||||
{
|
||||
profileData = profileData.Where((pair => filterRegex.IsMatch(pair.Key.Search))).ToList();
|
||||
Regex filterRegex = new Regex(FilterText, RegexOptions.IgnoreCase);
|
||||
if (FilterText != "")
|
||||
{
|
||||
profileData = profileData.Where((pair => filterRegex.IsMatch(pair.Key.Search))).ToList();
|
||||
}
|
||||
}
|
||||
catch (ArgumentException argException)
|
||||
{
|
||||
// Skip filtering for invalid regex
|
||||
}
|
||||
}
|
||||
catch (ArgumentException argException)
|
||||
else
|
||||
{
|
||||
// Skip filtering for invalid regex
|
||||
// Regular filtering
|
||||
profileData = profileData.Where((pair => pair.Key.Search.ToLower().Contains(FilterText.ToLower()))).ToList();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Regular filtering
|
||||
profileData = profileData.Where((pair => pair.Key.Search.ToLower().Contains(FilterText.ToLower()))).ToList();
|
||||
|
||||
ProfileUpdated = false;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
@ -421,13 +440,14 @@ namespace Ryujinx
|
|||
protected override void OnKeyPress(KeyPressEventArgs e)
|
||||
{
|
||||
FilterText += e.KeyChar;
|
||||
ProfileUpdated = true;
|
||||
}
|
||||
|
||||
protected override void OnKeyDown(KeyboardKeyEventArgs e)
|
||||
{
|
||||
if (e.Key == Key.BackSpace)
|
||||
{
|
||||
BackspaceDown = true;
|
||||
ProfileUpdated = BackspaceDown = true;
|
||||
return;
|
||||
}
|
||||
base.OnKeyUp(e);
|
||||
|
|
|
@ -72,6 +72,7 @@ namespace Ryujinx
|
|||
Enabled = Convert.ToBoolean(parser.Value("Profiling_Enabled")),
|
||||
FileDumpEnabled = profilePath != "",
|
||||
DumpLocation = profilePath,
|
||||
UpdateRate = 1.0f / Convert.ToInt32(parser.Value("Profiling_Update_Rate")),
|
||||
});
|
||||
|
||||
SystemLanguage SetLanguage = Enum.Parse<SystemLanguage>(parser.Value("System_Language"));
|
||||
|
|
|
@ -28,6 +28,9 @@ Profiling_Enabled = true
|
|||
#Set profile file dump location, if blank file dumping disabled. (e.g. `ProfileDump.csv`)
|
||||
Profile_Dump_Path = ProfileDump.csv
|
||||
|
||||
#Update rate for profiler UI, in hertz
|
||||
Profiling_Update_Rate = 4
|
||||
|
||||
#System Language list: https://gist.github.com/HorrorTroll/b6e4a88d774c3c9b3bdf54d79a7ca43b
|
||||
#Change System Language
|
||||
System_Language = AmericanEnglish
|
||||
|
|
Loading…
Add table
Reference in a new issue