forked from NickStrupat/CacheLineSize.NET
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CacheLine.cs
34 lines (33 loc) · 1.13 KB
/
CacheLine.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
using System;
using System.Runtime.InteropServices;
namespace Platform.Hardware.Cpu
{
/// <summary>
/// <para>Contains constants related to CPUs cache line.</para>
/// <para>Содержит константы, относящиеся к строке кэша ЦП.</para>
/// </summary>
public static class CacheLine
{
/// <summary>
/// <para>Gets the size of CPUs cache line in bytes.</para>
/// <para>Получает размер строки кэша ЦП в байтах.</para>
/// </summary>
public static readonly int Size = GetSize();
private static int GetSize()
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
return Windows.GetSize();
}
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
return Linux.GetSize();
}
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
return OSX.GetSize();
}
throw new NotSupportedException("Unrecognized OS platform.");
}
}
}