mirror of
https://github.com/danbulant/Cosmos
synced 2026-05-19 12:30:32 +00:00
21 lines
644 B
C#
21 lines
644 B
C#
using IL2CPU.API;
|
|
using IL2CPU.API.Attribs;
|
|
using System;
|
|
using System.Diagnostics;
|
|
using Cosmos.Core;
|
|
|
|
namespace Cosmos.Core_Plugs.System.Diagnostics
|
|
{
|
|
[Plug(Target = typeof(global::System.Diagnostics.Stopwatch))]
|
|
public class StopwatchImpl
|
|
{
|
|
public static long GetTimestamp()
|
|
{
|
|
if (Stopwatch.IsHighResolution)
|
|
// see https://msdn.microsoft.com/en-us/library/windows/desktop/dn553408(v=vs.85).aspx for more details
|
|
return (long)(CPU.GetCPUUptime() / (double)CPU.GetCPUUptime() * 1000000d);
|
|
else
|
|
return DateTime.UtcNow.Ticks;
|
|
}
|
|
}
|
|
}
|