1
0
Fork 0
mirror of https://github.com/Ryujinx/Ryujinx.git synced 2024-12-30 12:06:01 +00:00
Ryujinx/Ryujinx.Common/PerformanceCounter.cs
gdkchan 48278905d1
Rewrite scheduler context switch code (#1786)
* Rewrite scheduler context switch code

* Fix race in UnmapIpcRestorePermission

* Fix thread exit issue that could leave the scheduler in a invalid state

* Change context switch method to not wait on guest thread, remove spin wait, use SignalAndWait to pass control

* Remove multi-core setting (it is always on now)

* Re-enable assert

* Remove multicore from default config and schema

* Fix race in KTimeManager
2020-12-09 19:20:05 -03:00

82 lines
No EOL
2.2 KiB
C#
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System.Diagnostics;
namespace Ryujinx.Common
{
public static class PerformanceCounter
{
private static double _ticksToNs;
/// <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>
/// Gets the number of ticks elapsed since the system started.
/// </summary>
public static long ElapsedTicks
{
get
{
return Stopwatch.GetTimestamp();
}
}
/// <summary>
/// Gets the number of milliseconds elapsed since the system started.
/// </summary>
public static long ElapsedMilliseconds
{
get
{
long timestamp = Stopwatch.GetTimestamp();
return timestamp / TicksPerMillisecond;
}
}
/// <summary>
/// Gets the number of nanoseconds elapsed since the system started.
/// </summary>
public static long ElapsedNanoseconds
{
get
{
long timestamp = Stopwatch.GetTimestamp();
return (long)(timestamp * _ticksToNs);
}
}
static PerformanceCounter()
{
TicksPerMillisecond = Stopwatch.Frequency / 1000;
TicksPerSecond = Stopwatch.Frequency;
TicksPerMinute = TicksPerSecond * 60;
TicksPerHour = TicksPerMinute * 60;
TicksPerDay = TicksPerHour * 24;
_ticksToNs = 1000000000.0 / Stopwatch.Frequency;
}
}
}