Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ ProcessorNumberSpeedCheck()

static bool System.Threading.ProcessorIdCache.ProcessorNumberSpeedCheck ( )
inlinestaticpackage

Definition at line 35 of file ProcessorIdCache.cs.

36 {
37 double num = double.MaxValue;
38 double num2 = double.MaxValue;
40 if (Thread.GetCurrentProcessorNumber() < 0)
41 {
43 return false;
44 }
45 long num3 = Stopwatch.Frequency / 1000000 + 1;
46 for (int i = 0; i < 10; i++)
47 {
48 int num4 = 8;
49 long timestamp;
50 do
51 {
52 num4 *= 2;
53 timestamp = Stopwatch.GetTimestamp();
54 for (int j = 0; j < num4; j++)
55 {
56 Thread.GetCurrentProcessorNumber();
57 }
58 timestamp = Stopwatch.GetTimestamp() - timestamp;
59 }
60 while (timestamp < num3);
61 num = Math.Min(num, (double)timestamp / (double)num4);
62 num4 /= 4;
63 do
64 {
65 num4 *= 2;
66 timestamp = Stopwatch.GetTimestamp();
67 for (int k = 0; k < num4; k++)
68 {
70 }
71 timestamp = Stopwatch.GetTimestamp() - timestamp;
72 }
73 while (timestamp < num3);
74 num2 = Math.Min(num2, (double)timestamp / (double)num4);
75 }
76 s_processorIdRefreshRate = Math.Min((int)(num * 5.0 / num2), 5000);
77 return s_processorIdRefreshRate <= 5;
78 }

References System.Threading.Thread.GetCurrentProcessorNumber(), System.Diagnostics.Stopwatch.GetTimestamp(), System.Math.Min(), System.Threading.ProcessorIdCache.s_processorIdRefreshRate, and System.Threading.ProcessorIdCache.UninlinedThreadStatic().