Skip to content

Commit

Permalink
Forceinline timestamp properties, especially the non-core fallback one
Browse files Browse the repository at this point in the history
  • Loading branch information
neon-sunset committed Jun 26, 2023
1 parent c436740 commit a81e942
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/FastCache.Cached/Helpers/TimeUtils.cs
Expand Up @@ -3,11 +3,19 @@ namespace FastCache.Helpers;
internal static class TimeUtils
{
#if NETCOREAPP3_0_OR_GREATER
public static long Now => Environment.TickCount64;
public static long Now
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => Environment.TickCount64;
}
#else
private static readonly DateTime Offset = DateTime.UtcNow;

public static long Now => (DateTime.UtcNow - Offset).Ticks / TimeSpan.TicksPerMillisecond;
public static long Now
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => (DateTime.UtcNow - Offset).Ticks / TimeSpan.TicksPerMillisecond;
}
#endif

[MethodImpl(MethodImplOptions.AggressiveInlining)]
Expand Down

0 comments on commit a81e942

Please sign in to comment.