Timing: Rename ElapsedTicks to ElapsedMilliseconds and expose TicksPerX
This commit is contained in:
parent
7403db2f69
commit
646a3c57c7
6 changed files with 56 additions and 19 deletions
|
@ -138,7 +138,7 @@ namespace ChocolArm64
|
||||||
|
|
||||||
CacheBucket Bucket = Cache[Node.Value];
|
CacheBucket Bucket = Cache[Node.Value];
|
||||||
|
|
||||||
long TimeDelta = RingDelta(Bucket.Timestamp, Timestamp);
|
long TimeDelta = Bucket.Timestamp - Timestamp;
|
||||||
|
|
||||||
if (TimeDelta <= MinTimeDelta)
|
if (TimeDelta <= MinTimeDelta)
|
||||||
{
|
{
|
||||||
|
@ -159,12 +159,7 @@ namespace ChocolArm64
|
||||||
{
|
{
|
||||||
long timestamp = Stopwatch.GetTimestamp();
|
long timestamp = Stopwatch.GetTimestamp();
|
||||||
|
|
||||||
return (long)(timestamp * (1000.0f / Stopwatch.Frequency));
|
return timestamp / (Stopwatch.Frequency / 1000);
|
||||||
}
|
|
||||||
|
|
||||||
private static long RingDelta(long Old, long New)
|
|
||||||
{
|
|
||||||
return New - Old;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -4,6 +4,40 @@ namespace Ryujinx.Common
|
||||||
{
|
{
|
||||||
public static class PerformanceCounter
|
public static class PerformanceCounter
|
||||||
{
|
{
|
||||||
|
static PerformanceCounter()
|
||||||
|
{
|
||||||
|
TicksPerMillisecond = Stopwatch.Frequency / 1000;
|
||||||
|
TicksPerSecond = Stopwatch.Frequency;
|
||||||
|
TicksPerMinute = TicksPerSecond * 60;
|
||||||
|
TicksPerHour = TicksPerMinute * 60;
|
||||||
|
TicksPerDay = TicksPerHour * 24;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Represents the number of ticks in 1 day.
|
||||||
|
/// </summary>
|
||||||
|
public static long TicksPerDay { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Represents the number of ticks in 1 hour.
|
||||||
|
/// </summary>
|
||||||
|
public static long TicksPerHour { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Represents the number of ticks in 1 minute.
|
||||||
|
/// </summary>
|
||||||
|
public static long TicksPerMinute { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Represents the number of ticks in 1 second.
|
||||||
|
/// </summary>
|
||||||
|
public static long TicksPerSecond { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Represents the number of ticks in 1 millisecond.
|
||||||
|
/// </summary>
|
||||||
|
public static long TicksPerMillisecond { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the number of milliseconds elapsed since the system started.
|
/// Gets the number of milliseconds elapsed since the system started.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -13,7 +47,20 @@ namespace Ryujinx.Common
|
||||||
{
|
{
|
||||||
long timestamp = Stopwatch.GetTimestamp();
|
long timestamp = Stopwatch.GetTimestamp();
|
||||||
|
|
||||||
return (long)(timestamp * (1000.0f / Stopwatch.Frequency));
|
return timestamp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the number of milliseconds elapsed since the system started.
|
||||||
|
/// </summary>
|
||||||
|
public static long ElapsedMilliseconds
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
long timestamp = Stopwatch.GetTimestamp();
|
||||||
|
|
||||||
|
return timestamp / TicksPerMillisecond;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
||||||
this.DataSize = DataSize;
|
this.DataSize = DataSize;
|
||||||
this.Node = Node;
|
this.Node = Node;
|
||||||
|
|
||||||
Timestamp = PerformanceCounter.ElapsedTicks;
|
Timestamp = PerformanceCounter.ElapsedMilliseconds;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,7 +142,7 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
||||||
|
|
||||||
private void ClearCacheIfNeeded()
|
private void ClearCacheIfNeeded()
|
||||||
{
|
{
|
||||||
long Timestamp = PerformanceCounter.ElapsedTicks;
|
long Timestamp = PerformanceCounter.ElapsedMilliseconds;
|
||||||
|
|
||||||
int Count = 0;
|
int Count = 0;
|
||||||
|
|
||||||
|
@ -157,7 +157,7 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
||||||
|
|
||||||
CacheBucket Bucket = Cache[Node.Value];
|
CacheBucket Bucket = Cache[Node.Value];
|
||||||
|
|
||||||
long TimeDelta = RingDelta(Bucket.Timestamp, Timestamp);
|
long TimeDelta = Bucket.Timestamp - Timestamp;
|
||||||
|
|
||||||
if ((uint)TimeDelta <= (uint)MaxTimeDelta)
|
if ((uint)TimeDelta <= (uint)MaxTimeDelta)
|
||||||
{
|
{
|
||||||
|
@ -171,10 +171,5 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
||||||
DeleteValueCallback(Bucket.Value);
|
DeleteValueCallback(Bucket.Value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private long RingDelta(long Old, long New)
|
|
||||||
{
|
|
||||||
return New - Old;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -851,7 +851,7 @@ namespace Ryujinx.Graphics
|
||||||
//TODO: Implement counters.
|
//TODO: Implement counters.
|
||||||
long Counter = 1;
|
long Counter = 1;
|
||||||
|
|
||||||
long Timestamp = PerformanceCounter.ElapsedTicks;
|
long Timestamp = PerformanceCounter.ElapsedMilliseconds;
|
||||||
|
|
||||||
Timestamp = (long)(Timestamp * 615384.615385);
|
Timestamp = (long)(Timestamp * 615384.615385);
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ namespace Ryujinx.HLE.HOS.Kernel
|
||||||
|
|
||||||
if (Thread != null)
|
if (Thread != null)
|
||||||
{
|
{
|
||||||
Thread.LastScheduledTicks = PerformanceCounter.ElapsedTicks;
|
Thread.LastScheduledTicks = PerformanceCounter.ElapsedMilliseconds;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SelectedThread != CurrentThread)
|
if (SelectedThread != CurrentThread)
|
||||||
|
|
|
@ -216,7 +216,7 @@ namespace Ryujinx.HLE.Input
|
||||||
|
|
||||||
private static long GetTimestamp()
|
private static long GetTimestamp()
|
||||||
{
|
{
|
||||||
return PerformanceCounter.ElapsedTicks * 19200;
|
return PerformanceCounter.ElapsedMilliseconds * 19200;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue